help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bad_alloc thrown but plenty of memory left


From: Bernd Strieder
Subject: Re: bad_alloc thrown but plenty of memory left
Date: Thu, 17 Apr 2008 15:56:48 +0200
User-agent: KNode/0.10.4

Hello,

Martin wrote:

> I have a program compiled with g++ 4.1.3 on Ubuntu 7.10. I frequently
> get std::bad_alloc exceptions from new when trying to allocate a
> couple of thousand objects of around 160 bytes each. According to top,
> my program uses about 30 MB of memory when I get the exception, and
> there is 1 GB of memory available. Can someone explain why I get a
> bad_alloc under such circumstances?

You have to be much more specific to get more than guesswork. Copy your
project, and try to reduce it to the minimum code still showing the
problem. Ideally you find the problem yourself in the course, otherwise
the code is probably simple enough that you can get help here posting
the code so the problem can be reproduced.

Try running the program with valgrind to find many kinds of
memory-related problems easier.

Bernd Strieder



reply via email to

[Prev in Thread] Current Thread [Next in Thread]