Java 非堆内存和栈内存有什么区别?它们是否相同,如果不同,它们之间有什么区别? [英] What is the difference between Java Non Heap Memory and Stack Memory? Are they Same if not what is the difference between them?

查看:35
本文介绍了Java 非堆内存和栈内存有什么区别?它们是否相同,如果不同,它们之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Jconsole 来监控 Java 应用程序.内存选项卡显示不同的堆和非堆内存,例如

I am using Jconsole for monitoring a Java Application. The memory tab shows different Heap and Non Heap memories like

  1. 堆内存使用情况
  2. 非堆内存使用情况
  3. 内存池CMS Old Gen"
  4. 内存池Par Eden Space"
  5. 内存池Par Survivor Space"
  6. 内存池代码缓存"
  7. 内存池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):

  1. 堆栈
  2. 静态(有多种变体)

你熟悉的堆.

您也熟悉堆栈,但您不知道.当您有一个带有局部"变量的方法时,这些变量会在调用框架"中分配.调用帧"在调用方法时分配,从方法返回时删除,因此使用随调用增长并随返回收缩的堆栈"最有效地实现.

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.

这篇关于Java 非堆内存和栈内存有什么区别?它们是否相同,如果不同,它们之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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