简体   繁体   English

奇怪的c ++内存使用情况

[英]Strange c++ memory usage

I have the follow class: 我有以下课程:

class testclass{
    int a[5];
};

and the following main function: 以及主要功能:

int main(int argc, const char * argv[])  
{
    testclass* t;
    while(true)
        t = new testclass();
    return 0;
}

So I exected this to just fill up all of my memory really quickly. 所以我这么做就是为了快速填满我的所有记忆。 But this is the memory usage graph that xcode is giving me: 但这是xcode给我的内存使用情况图:

在此输入图像描述

Which I don't understand at all. 我根本不明白。 How can the memory usage possibly go down in this program? 在这个程序中,内存使用情况怎么可能会下降?

oke answered. 奥克回答。 The graph seems to only show physical memory usage. 该图似乎只显示物理内存使用情况。 When I go the the activity monitor, I can see that the virtual memory usage is huge: 当我进入活动监视器时,我可以看到虚拟内存使用量巨大:

在此输入图像描述

That's in dutch but I think you'll understand it. 这是荷兰语,但我想你会明白的。

Thanks for the answers 谢谢你的回答

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM