Operating System - HP-UX
1748128 Members
4267 Online
108758 Solutions
New Discussion

Re: operator new[] throws std::bad_alloc

 
Dennis Handly
Acclaimed Contributor

Re: operator new[] throws std::bad_alloc

>My executable is 64 bit.

 

There are N ways to not being able to allocate heap space:

1) maxdsiz (and maxdsiz_64) is too small.

2) You have set ulimit too small.  This will only affect 32 bit processes.  Really the same as 3).

3) You have used setrlimit to reduce the data area.  RLIMIT_DATA

4) You have used setrlimit to reduce the total memory.  RLIMIT_AS

5) You are asking for 3+GB more and that exceeds 4 GB.

6) The heap is corrupted.

 

To find the values for 3) and 4) above, you need to write a program to call getrlimit(2).

With both resources:

   getrlimit(RLIMIT_AS, ...);

   getrlimit(RLIMIT_DATA, ...);