terminate called after throwing an instance of 'std::bad_alloc'

M

Mohsen

Hello everyone,

In my program, I have to define many pointers and when I want to
compile my program (in UNIX), it gives me the following error:

terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
Abort

I rechecked those pointers; I found I cannot decrease the size of them.
Any idea how I can to solve this problem?

Thanks,
Mohsen
 
M

mlimber

Mohsen said:
Hello everyone,

In my program, I have to define many pointers and when I want to
compile my program (in UNIX), it gives me the following error:

terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
Abort

I rechecked those pointers; I found I cannot decrease the size of them.
Any idea how I can to solve this problem?

Are you saying your compiler terminates? If so, ask your compiler
vendor.

If you are talking about your program, then you don't have sufficient
memory to allocate whatever you are trying to allocate. If you can't
decrease the size of what you are allocating (or otherwise provide
enough space) and can't add more memory to your computer, then you're
sunk.

Cheers! --M
 
G

Gianni Mariani

Mohsen said:
Hello everyone,

In my program, I have to define many pointers and when I want to
compile my program (in UNIX), it gives me the following error:

terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
Abort

I rechecked those pointers; I found I cannot decrease the size of them.
Any idea how I can to solve this problem?

Without seeing your code it's impossible to tell what is going on.

I have no idea what you mean by "cannot decrease the size".
 
D

Daniel T.

Mohsen said:
In my program, I have to define many pointers and when I want to
compile my program (in UNIX), it gives me the following error:

terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
Abort

During the compile, or while your program is running?
 
F

Frederick Gotham

Mohsen:
it happens during the compile.


First guess would be that your compiler is running out of memory. Try closing
as many applications as possible, then try re-compile.

Second guess would be that your compiler is broken... but I don't see how a
bug could result in the throwing of a bad_alloc.
 
J

Jim Langston

Mohsen said:
Hello everyone,

In my program, I have to define many pointers and when I want to
compile my program (in UNIX), it gives me the following error:

terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
Abort

I rechecked those pointers; I found I cannot decrease the size of them.
Any idea how I can to solve this problem?

Thanks,
Mohsen

You say it's happening when you are tryign to compile, not run your program.
The first thing I would do would attempt to get a newer version of the
compiler. If that didnt' work, I would google for my compiler name and
"bad_alloc" and see if I got any hits. If that didnt' work I"d post in a
newsgroup for my compiler.
 
N

Nate Barney

Jim said:
You say it's happening when you are tryign to compile, not run your program.
The first thing I would do would attempt to get a newer version of the
compiler. If that didnt' work, I would google for my compiler name and
"bad_alloc" and see if I got any hits. If that didnt' work I"d post in a
newsgroup for my compiler.

What does the standard say about recursive templates? For instance, g++
3.4.4 issues a reasonable diagnostic with the following, but is it
required to? Seems like this could be something that might cause a
compiler to throw std::bad_alloc.

template <unsigned long N>
class A
{
public:

static const unsigned long a = A<N+1>::a;
};

int main()
{
unsigned long i = A<0>::a;
}

Nate
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,191
Latest member
BuyKetoBeez

Latest Threads

Top