堆栈与堆 [英] Stack vs. Heap

查看:51
本文介绍了堆栈与堆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我在常见问题解答中找不到明显的答案。我的基本问题,

是:在堆上与堆栈分配有什么区别吗?如果
堆或堆栈实现不是标准的一部分,那么只需

忽略这个问题。这里有一些我很困惑的问题,如果

你可以添加其他东西,请这样做!


堆栈是否有限每个程序?


另一方面,堆基本上是无限的(除了当然限制内存或页面文件大小的
)? />

如果我已经掌握了一些东西,据我所知,另一个程序可以在我不知情的情况下更新我分配的任何存储空间吗?这可能发生在堆栈上吗?


堆栈上使用变量与堆上的变量是否有任何性能差异? ?


堆栈中是否有全局和静态变量?


我问的原因是我开始进入C#,关于在垃圾收集堆上分配大量内容,这是一笔大不了的事。

。我不会想要开始讨论题外话题,所以我只想问一下:像这样的

概念会从堆积的事实出发存储最好使用

出于某种原因而不是堆叠存储?


我很感激!

Kevin Grigorenko < br>

Hello,

I couldn''t find an obvious answer to this in the FAQ. My basic question,
is: Is there any difference in allocating on the heap versus the stack? If
heap or stack implementation is not part of the standard, then just
disregard this question. Here''s some questions I''m confused about, and if
you can add anything else, please do so!

Is the stack limited for each program?

On the other hand, is the heap basically limitless (except of course limited
to the size of memory or page files)?

If I''ve got something on the heap, as I understand it, another program can
update any of my allocated storage without me knowing? Can this happen on
the stack?

Is there any performance difference in using variables on the stack versus
on the heap?

Are global and static variables on the stack?

The reason I ask is I''m starting to get into C#, and it makes a big deal
about allocating a lot of stuff on a garbage collected heap. I wouldn''t
want to start asking off-topic questions, so I''ll just ask this: would a
concept like this follow from the fact that heap storage is better to use
for some reason rather than storage on the stack?

I appreciate it!
Kevin Grigorenko

推荐答案

Kevin Grigorenko写道:
Kevin Grigorenko wrote:


我找不到常见问题解答中有一个明显的答案。我的基本问题是:在堆上分配堆栈与堆栈有什么不同吗?
如果堆或堆栈实现不是标准的一部分,那么只是忽略这个问题。这里有一些我很困惑的问题,如果
你可以添加其他东西,请这样做!

每个程序的堆栈是否有限?
<另一方面,堆基本上是无限的(当然除了内存或页面文件的大小有限)?

如果我在堆上有东西据我所知,另一个程序可以在我不知情的情况下更新我分配的任何存储空间?这可能发生在堆栈上吗?

在堆栈上使用变量与堆上的
有任何性能差异吗?

是全局的堆栈上的静态变量?

我问的原因是我开始进入C#,并且在垃圾收集堆上分配很多东西是很重要的。我不想开始提出偏离主题的问题,所以我只想问一下:这样的概念是否会从堆存储更好地使用
出于某种原因而不是存储在堆栈上?


I couldn''t find an obvious answer to this in the FAQ. My basic question,
is: Is there any difference in allocating on the heap versus the stack?
If heap or stack implementation is not part of the standard, then just
disregard this question. Here''s some questions I''m confused about, and if
you can add anything else, please do so!

Is the stack limited for each program?

On the other hand, is the heap basically limitless (except of course limited
to the size of memory or page files)?

If I''ve got something on the heap, as I understand it, another program can
update any of my allocated storage without me knowing? Can this happen on
the stack?

Is there any performance difference in using variables on the stack versus
on the heap?

Are global and static variables on the stack?

The reason I ask is I''m starting to get into C#, and it makes a big deal
about allocating a lot of stuff on a garbage collected heap. I wouldn''t
want to start asking off-topic questions, so I''ll just ask this: would a
concept like this follow from the fact that heap storage is better to use
for some reason rather than storage on the stack?




这取决于你的编译器。

请告诉我们你使用的是哪个编译器

以便我们可以重定向到相应的新闻组。



It depends upon your compiler.
Please tell us which compiler you are using
so that we can redirect to to the appropriate newsgroup.


" E. Robert Tisdale <,E ************** @ jpl.nasa.gov>。在消息中写道

新闻:3F ************** @ jpl.nasa.gov ...
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:3F**************@jpl.nasa.gov...
Kevin Grigorenko写道:
Kevin Grigorenko wrote:


我在常见问题解答中找不到明显的答案。我的基本
问题是:在堆上与堆栈分配有什么区别吗?
如果堆或堆栈实现不是标准的一部分,那么只是忽略这个问题。这里有一些我很困惑的问题,如果你可以添加其他任何东西,还有
,请这样做!

每个程序的堆栈是否有限?
<另一方面,堆基本上是无限的(除了当然
限于内存或页面文件的大小)?

如果我在堆上有东西据我所知,另一个程序
可以在我不知情的情况下更新我分配的任何存储空间?这可能会在堆栈上发生
吗?

使用堆栈
与堆上的变量有什么性能差异?

是全局的堆栈上的静态变量?

我问的原因是我开始进入C#,并且在垃圾收集堆上分配很多东西是很重要的。我不想开始提出偏离主题的问题,所以我只想问一下:像这样的概念是否会从堆存储更好到
这一事实出发使用是出于某种原因而不是存储在堆栈上?


I couldn''t find an obvious answer to this in the FAQ. My basic question, is: Is there any difference in allocating on the heap versus the stack?
If heap or stack implementation is not part of the standard, then just
disregard this question. Here''s some questions I''m confused about, and if you can add anything else, please do so!

Is the stack limited for each program?

On the other hand, is the heap basically limitless (except of course limited to the size of memory or page files)?

If I''ve got something on the heap, as I understand it, another program can update any of my allocated storage without me knowing? Can this happen on the stack?

Is there any performance difference in using variables on the stack versus on the heap?

Are global and static variables on the stack?

The reason I ask is I''m starting to get into C#, and it makes a big deal
about allocating a lot of stuff on a garbage collected heap. I wouldn''t
want to start asking off-topic questions, so I''ll just ask this: would a
concept like this follow from the fact that heap storage is better to use for some reason rather than storage on the stack?



这取决于你的编译器。
请告诉我们你正在使用哪个编译器
以便我们可以重定向到适当的新闻组。



It depends upon your compiler.
Please tell us which compiler you are using
so that we can redirect to to the appropriate newsgroup.




所有这些问题都是非标准的?好的,我毫不怀疑,你们是专家们的b $ b。让我们说我正在使用的编译器是VC ++ 6。另外,我是在寻找一个C#新闻组,所以如果你也可以指引我到我可以发布的问题,那么就会很好。我无法找到

comp.lang.csharp的效果。


堆栈和堆的概念是否完全独立于标准?


再次感谢!

Kevin Grigorenko



All of those questions are non-standard? Ok, I have no doubts, you guys are
the experts. Let''s say the compiler I''m using is VC++6. Also, I was
looking for a C# newsgroup, so if you could also direct me to where I can
post questions regarding that, that would be great. I couldn''t find
anything to the effect of comp.lang.csharp.

Is the concept of stack and heap completely independent of the standard?

Thanks again!
Kevin Grigorenko


>另外,我是
正在寻找一个C#新闻组,所以如果你也可以指导我到哪里发布有关它的问题,那就太好了。我无法找到comp.lang.csharp的效果。
looking for a C# newsgroup, so if you could also direct me to where I can
post questions regarding that, that would be great. I couldn''t find
anything to the effect of comp.lang.csharp.




在微软的新闻服务器上(msnews.microsoft.com ) -

microsoft.public.dotnet.languages.csharp。



On Microsoft''s news server (msnews.microsoft.com) -
microsoft.public.dotnet.languages.csharp.


这篇关于堆栈与堆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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