.net(或java)中的字符串如何存储 [英] How do strings in .net( or java) gets stored

查看:85
本文介绍了.net(或java)中的字符串如何存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以告诉我:
.net(或java)中的字符串如何存储...在连续的内存位置或任何地方(如果找不到连续的位置).

预先thx

hI Can anybody tell me that :
How do strings in .net( or java) gets stored...in a contigious memory location OR anywhere (if it does not find a contingious location) .

thx in advance

推荐答案

内存分配的本质是所分配的内存块是连续的.一旦释放,它可能永远不会被应用程序再次使用.过去,这可能称为堆碎片",如果分配内存块所需的程序运行了足够长时间而实际上没有足够大的内存块来满足所需的内存,则通常会使该程序崩溃分配.

.Net的垃圾收集器应该可以解决该问题.关于javascript,我不知道它在垃圾回收和堆恢复方面的本质.
The nature of memory allocation is that the allocated block of memory is continguous. Once deallocated, it may never be used again by the application. Back in the day, this could call something known as "heap fragmentation", and would generally crash a program if that program needed to allocate a block of memory had been running long enough to effectively leave no blocks of memory large enough to satisfy the necessary allocation.

.Net''s garbage collector is supposed to remedy that problem. Regarding javascript, I don''t know the nature of it regarding garbage collecting and heap recovery.


对于.NET,字符串是一个完全模仿值语义的引用类.根据实习生的想法,它的存储是非常重要的.

请在此处查看有关相关主题(包括我的主题)的最新答案:字符串是引用类型或值类型 [
As to .NET, string is a reference class thoroughly mimicking value semantic. It''s storage is quite non-trivial, based on the idea of interning.

Please see recent answers on related topic, including mine, here: string is a reference type or value type[^].

—SA


这篇关于.net(或java)中的字符串如何存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆