堆栈和堆都存在于系统RAM中吗? [英] Do the Stack and Heap both exist within your systems RAM?

查看:385
本文介绍了堆栈和堆都存在于系统RAM中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题与标题几乎相同,堆栈和堆是否始终存在于RAM中?假设Windows是有问题的计算机的操作系统.

The question is pretty much the same as the title, do the Stack and Heap exist within the RAM at all times? Assuming Windows is the OS of the machine in question.

此外,如果对上述问题的回答是是",是否可以告诉JVM在不同的位置(例如外部micro SD卡)创建特定的应用程序堆栈和堆?还是仅将默认的堆栈/堆创建位置设置为RAM以外的其他位置?

Also, if the answer to the above question is yes, is it possible to tell the JVM to create a specific applications Stack and Heap in a different location, such as an external micro SD card? Or to just set the default Stack/Heap creation location to some location other than RAM?

推荐答案

好吧,它们可能并非在全部时间内都位于RAM中.堆栈和堆只是在RAM中分配的数据结构.当您的程序实际使用CPU时,它们都将(至少部分地)存在于RAM中.但是,当程序不运行时,操作系统可能会交换掉堆栈和堆所在的页面.然后可以将部分(或全部)堆栈和堆写入磁盘.

Well, they might not be in RAM at all times. The stack and heap are just data structures allocated in RAM. When your program is actually using the CPU, they both will exist (at least partially) in RAM. However, it is possible that the OS will swap out the pages that the stack and heap are on when the program is not running. Then part of (or all) of the stack and heap could be written to disk.

我猜您将无法告诉JVM在其他任何地方分配这些数据结构.我无法想象您想要的情况.这将是极其缓慢的.我确定它们是使用malloc()或系统调用分配的,并且JVM不太可能具有用于该类型分配的任何条件代码.

I would guess that you would not be able to tell the JVM to allocate those data structures any place else. I cannot picture a scenario where you would want to; it would be horrifically slow. I am sure they are allocated with malloc() or a system call and it is unlikely the JVM would have any conditional code for that type of allocation.

这篇关于堆栈和堆都存在于系统RAM中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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