我的内存耗尽了吗? [英] am I running out of memory?

查看:74
本文介绍了我的内存耗尽了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

或者只是放弃它?


我有一个小的c ++应用程序,可生成数百万个bitset

类对象的组合,并将它们添加到STL地图中。


(感谢所有回复我之前发布的关于

增加程序速度的人)


无论如何,我计算我的bitset类对象大小为8字节,当我在调试模式下运行时,我可以在从AfxMem抛出

异常之前生成19,675,656个对象.cpp第341行。


我不明白为什么我只能得到那么多而不是很多

更多。 19,675,656,000次8是157,405,208,这比我在这台机器上运行的1 gig内存要少得多。我知道我没有得到整个演出并且感谢虚拟记忆

我有2个演出可用但是我不明白我为什么甚至没有得到接近那个标记的



你认为它真的是内存不足还是我在记忆中踩踏我

不应该。我不认为我是。


另一件事是我有异常处理程序,但他们是

没有捕获异常所以我'我不确定那里会发生什么。


感谢您的帮助。

问候

Or just loosing it?

I have a small c++ app which generates millions combinations of bitset
class objects and adds them to a STL map.

(on a side thanks to all who responded to my earlier posting about
increasing the programs speed)

Anyway, I calculate my bitset class object size to be 8 bytes and when
I run this in debug mode I can generate 19,675,656 objects before an
exception is thrown from AfxMem.cpp line 341.

What I don''t understand is why I only get that many and not a whole lot
more. 19,675,656 million times 8 is 157,405,208 which is significantly
less than the 1 gig of memory I have running on this machine. I
understand that I don''t get the whole gig and thanks to virtual memory
I have 2 gig available but I don''t understand why I''m not even getting
close to that mark.

Do you think its truly out of memory or am I trampling on on memory I
shouldn''t be. I don''t think I am.

One other thing is that I have exception handlers in place but they are
not catching the exception so I''m not sure whats going on there.

Thanks for any help.
Regards

推荐答案

Rich S写道:
或者只是放弃它?

我有一个小的c ++应用程序,可以生成数百万个bitset组合类对象并将它们添加到STL地图。

(感谢所有回复我之前发布的关于
提高程序速度的人)

无论如何,我计算我的bitset类对象大小为8个字节,当我在调试模式下运行时,我可以在从AfxMem.cpp行341抛出
异常之前生成19,675,656个对象。


我不知道'AfxMem.cpp'是什么或者它是什么样的341.

你想发布它并忘了?

我的意思我不明白为什么我只能得到那么多,而不是更多。 19,675,656,000次8是157,405,208,这远远低于我在这台机器上运行的1 gg内存。我知道我没有得到整个演出,并且感谢虚拟记忆我有2个演出可用,但我不明白为什么我甚至没有接近那个标记。


您的系统在每个对象上产生多少开销

在免费商店中创建?也许你应该尝试一个自定义分配器

或者什么...相同大小的1900万个对象只是在数组或其他东西中预先分配
。 br />
你认为它真的是内存不足还是我在记忆中踩踏我不应该。我不认为我是。


然后我和谁发生冲突?

另一件事是我有异常处理程序,但是他们没有抓住异常所以我不确定那里会发生什么。
Or just loosing it?

I have a small c++ app which generates millions combinations of bitset
class objects and adds them to a STL map.

(on a side thanks to all who responded to my earlier posting about
increasing the programs speed)

Anyway, I calculate my bitset class object size to be 8 bytes and when
I run this in debug mode I can generate 19,675,656 objects before an
exception is thrown from AfxMem.cpp line 341.
I have no idea what ''AfxMem.cpp'' is or what is in its like 341. Did
you mean to post it and forgot?
What I don''t understand is why I only get that many and not a whole
lot more. 19,675,656 million times 8 is 157,405,208 which is
significantly less than the 1 gig of memory I have running on this
machine. I understand that I don''t get the whole gig and thanks to
virtual memory I have 2 gig available but I don''t understand why I''m
not even getting close to that mark.
How much overhead does your system produce on top of every object
created in the free store? Perhaps you should try a custom allocator
or something... 19 million objects of the same size are just begging
to be pre-allocated in an array or something.
Do you think its truly out of memory or am I trampling on on memory I
shouldn''t be. I don''t think I am.
Then who am I to contradict you?
One other thing is that I have exception handlers in place but they
are not catching the exception so I''m not sure whats going on there.




什么例外的犯罪者?抛出什么异常?


V



What exception handers? What exception is thrown?

V


Rich S写道:
Rich S wrote:
或只是放弃它?

我有一个小的c ++应用程序,可以生成数百万个bitset
类对象的组合,并将它们添加到STL地图。

(在一边感谢所有回复我之前关于提高程序速度的帖子的人。

无论如何,我将我的bitset类对象大小计算为8个字节,当我运行它时调试模式我可以在从AfxMem.cpp第341行抛出
异常之前生成19,675,656个对象。

我不明白为什么我只能得到那么多而不是很多
更多。 19,675,656,000次8是157,405,208,这比我在这台机器上运行的1 gg内存要小得多。我明白我没有得到整个演出并感谢虚拟记忆
我有2个演出可用,但我不明白为什么我甚至没有得到
关闭到那个标记。


Hm,你的std :: set< T> class很可能被实现为某种类型的b $ b b平衡树,即你的对象将被存储为看起来像这样的节点:

有点像这样:

struct node {

T data_field;

node * right;

node * left;

节点*父级;

some_type balancing_info;

}


另外,请记住新的/删除机制很可能添加另一个

字的内存来跟踪删除时可以回收多少内存。

因此,根据处理平衡信息的方式,你可能会得到

每个节点略高于32个字节。在这种情况下,调用new might

实际上保留了每个节点48或64字节的东西,这将是6

到你计算的8倍。 />
你认为它真的是内存不足还是我在记忆中踩踏我不应该。我不认为我是。

另一件事是我有异常处理程序,但他们没有抓住异常,所以我不知道那里发生了什么。

感谢您的帮助。
问候
Or just loosing it?

I have a small c++ app which generates millions combinations of bitset
class objects and adds them to a STL map.

(on a side thanks to all who responded to my earlier posting about
increasing the programs speed)

Anyway, I calculate my bitset class object size to be 8 bytes and when
I run this in debug mode I can generate 19,675,656 objects before an
exception is thrown from AfxMem.cpp line 341.

What I don''t understand is why I only get that many and not a whole lot
more. 19,675,656 million times 8 is 157,405,208 which is significantly
less than the 1 gig of memory I have running on this machine. I
understand that I don''t get the whole gig and thanks to virtual memory
I have 2 gig available but I don''t understand why I''m not even getting
close to that mark.
Hm, your std::set< T > class very likely is implemented as some kind of
balanced tree, i.e., your objects will be stored as nodes that look
somewhat like this:

struct node {
T data_field;
node* right;
node* left;
node* parent;
some_type balancing_info;
}

Also, keep in mind that the new/delete mechanism is likely to add another
word of memory to keep track of how much memory can be reclaimed at delete.
Thus, depending on how balancing information is handled, you might get
slightly above 32 bytes per node. In that case, a call to new might
actually reserve something like 48 or 64 bytes per node, which would be 6
to 8 times more than you calculated.
Do you think its truly out of memory or am I trampling on on memory I
shouldn''t be. I don''t think I am.

One other thing is that I have exception handlers in place but they are
not catching the exception so I''m not sure whats going on there.

Thanks for any help.
Regards






Kai-Uwe Bux写道:
Kai-Uwe Bux wrote:

另外,请记住,新/删除机制可能会添加另一个内存字,以跟踪删除时可以回收的内存量。
因此,根据处理平衡信息的方式,每个节点可能会略高于32个字节。在这种情况下,呼叫新的可能实际上保留每个节点48或64字节的东西,这将是你计算的6到8倍。

Also, keep in mind that the new/delete mechanism is likely to add another
word of memory to keep track of how much memory can be reclaimed at delete.
Thus, depending on how balancing information is handled, you might get
slightly above 32 bytes per node. In that case, a call to new might
actually reserve something like 48 or 64 bytes per node, which would be 6
to 8 times more than you calculated.




是的,地图和集合使用的内存远远超出人们的预期,特别是对于小型数据对象来说,是
。当你需要管理如此大量的物体时,矢量或双端队列会更好地使用

的可用内存。


-


Pete Becker

Dinkumware,Ltd。( http://www.dinkumware.com


这篇关于我的内存耗尽了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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