Java 非堆内存和栈内存有什么区别?它们是否相同,如果不同,它们之间有什么区别?
我正在使用 Jconsole 来监控 Java 应用程序.内存选项卡显示不同的堆和非堆内存,例如
I am using Jconsole for monitoring a Java Application. The memory tab shows different Heap and Non Heap memories like
- 堆内存使用情况
- 非堆内存使用情况
- 内存池CMS Old Gen"
- 内存池Par Eden Space"
- 内存池Par Survivor Space"
- 内存池代码缓存"
- 内存池CMS Perm Gen"
这些术语之间有什么区别.还请提供一些关于 - 如何通过监控这些参数来发现应用程序行为异常的信息.
What is the difference between these terms. Also please provide some information regarding - how to find anomalies in the application behavior by monitoring these parameters.
推荐答案
在所有基于 C 的语言(以及大多数其他语言)中,基本上都有三类存储:
There are essentially three categories of storage in all C-based languages (and most other languages):
- 堆
- 堆栈
- 静态(有多种变体)
你熟悉的堆.
您也熟悉堆栈,但您不知道.当您有一个带有局部"变量的方法时,这些变量会在调用框架"中分配.调用帧"在调用方法时分配,从方法返回时删除,因此使用随调用增长并随返回收缩的堆栈"最有效地实现.
Stack you're also familiar with, but you just don't know it. When you have a method with "local" variables, those variables are allocated in a "invocation frame". The "invocation frame" is allocated when you call the method and deleted when you return from the method, and hence it's most efficiently implemented using a "stack" that grows with call and shrinks with return.
静态是你没有明确分配的东西,基本上从程序执行开始就存在.
Static is stuff that you don't explicitly allocate and essentially exists from the time program execution begins.
堆栈所需的空间通常相当小,与上述类别中的非堆内存"混为一谈.
The space required for stack is generally fairly small and is lumped in with "Non Heap Memory" in the categories above.
相关文章