I have a C++ application which I could compile successfully using Sun Studio 11 in the optimization mode (-O2). But when I upgraded the compiler to Sun Studio 12, it fails with following error message:
cg_memory_allocation: allocated 2131329024 bytes memory
cg: cg_memory_allocation.malloc: out of memory
cg: 1 errors
gmake: *** [application.o] Error 1
gmake: *** Deleting file `application.o'
I use gmake tool to invoke the compilation.
NB: If I compile in debug mode (-g) without optimization ON, then the compilation goes fine. The failure is only happening when optimization mode is ON.
Can anybody help me what could be the problem here?
Any pointer would be helpful.
Thanks in advance.
It looks like only about 2 GB was allocated
before virtual memory ran out.
I think it should be able to allocate closer
to 3.5 GB of heap memory.
Perhaps you need more physical memory or swap,
or perhaps something else was consuming memory too.
Generally speaking, making your source files smaller
(less functions, less lines of code, less initialized data)
by splitting larger files into multiple smaller ones
will tend to help the compiler use less memory.
Also, the advice about moving to a newer compiler may help.
Thanks for the quick reply. Is there any way I can check which version I have. I am sorry, I dont know how to check the version of Sun Studio.
This is what I get when I execute the cc compiler version:
cc: Sun C 5.9 SunOS_sparc Patch 124867-11 2009/04/30
1) The machine has huge amount of memory, ~32 GB of physical memory installed, 30GB free.
e.g. top command output:
Memory: 32G real, 30G free, 524M swap in use, 34G swap free
So does not look like a memory config issue.
2) I will update the Sun Studio to update 3 (12.3) and try again.
Thank you all for all your suggestions.
If the build failure is holding you up from going forward, you could compile just this file without optimization while continuing to optimize other files. Then in the background, you could try to modify the function(s) in the file to make them smaller and try again.