一个奇怪的记忆问题 [英] a weird memory problem

查看:81
本文介绍了一个奇怪的记忆问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个奇怪的内存问题。


我的c ++代码在执行时遇到了分段错误。为什么我试着用bdb调试它,我发现这是因为早期的内存问题。

然后我用了valgrind和efence工具,都告诉我早期

''新''操作失败。


但我有一个try {} catch(std:bad_alloc){}块来捕获坏内存

分配例外。为什么它没被抓住?


顺便说一下,我有足够的代码可用于代码,为什么

i仍然会得到错误的内存分配错误?


谢谢

I ran into a weird memory problem.

my c++ code got a segmentation error at the execution. why I try to
debug it with gdb, I found out it was due to an earlier memory problem.
I then used both valgrind and efence tools, both tell me that an early
''new'' operation failed.

But I have a try{}catch(std:bad_alloc){} block to catch bad memory
allocation exceptions. why it wasn''t caught?

By the way, I have more than enough momory available for the code, why
i still get a bad memory allocation error?

thanks

推荐答案

< ne ******* *@gmail.com>在消息中写道

news:11 ********************** @ o13g2000cwo.googlegr oups.com ...
<ne********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
我遇到了一个奇怪的内存问题。

我的c ++代码在执行时遇到了分段错误。为什么我尝试用gdb调试它,我发现它是由于早期的内存问题。
然后我使用了valgrind和efence工具,都告诉我早期的
''新的''操作失败。

但是我有一个try {} catch(std:bad_alloc){}块来捕获错误的内存分配异常。为什么它没被抓住?

顺便说一下,我有足够的代码可用于代码,为什么
我仍然会收到错误的内存分配错误?
I ran into a weird memory problem.

my c++ code got a segmentation error at the execution. why I try to
debug it with gdb, I found out it was due to an earlier memory problem.
I then used both valgrind and efence tools, both tell me that an early
''new'' operation failed.

But I have a try{}catch(std:bad_alloc){} block to catch bad memory
allocation exceptions. why it wasn''t caught?

By the way, I have more than enough momory available for the code, why
i still get a bad memory allocation error?




第42行的错误。


-Mike



Bug on line 42.

-Mike


你能解释一下吗更多细节?

感谢

can you explain it in more detail?
thanks


ne ******** @ gmail.com 写道:
你能更详细地解释一下吗?
谢谢
can you explain it in more detail?
thanks



在互联网上,小管道的人经常采用高压缩的通信形式,以节省时间和金钱

上传他们的回复。 第42行的Bug。解压缩到你有

描述你的问题是多么可怜的细节,你的悲伤

确实是悲伤的,但你没有充分/描述/你的/>
问题,也许是通过发布代码的合理大小的片段来确定问题。也许如果你要更全面地描述你的代码和问题,我们可能会帮助你,但在那之前我们可以

只能疯狂而毫无结果地推测。


显然,第42行的Bug。更加简洁。


On the internet, people with small pipes frequently resort to a
highly-compressed form of communication, in order to save time and money
on uploading their replies. "Bug on line 42." decompresses to "You have
described how woeful your problem is in great detail, and your sorrows
are indeed sorrowful, but you have not adequately /described/ your
problem, perhaps by posting reasonably sized snippets of the code which
is causing you issues. Perhaps if you were to describe your code and
your problem more thoroughly, we might help you, but until then we can
only speculate wildly and fruitlessly."

Obviously, "Bug on line 42." is much more concise.


这篇关于一个奇怪的记忆问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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