Thread: Memory allocation fails
11-07-2008, 03:51 PM #1
Memory allocation fails
- Member Since
- Nov 07, 2008
I am facing problem in dynamically allocating memory using c++. It fails with the following error msg.
main(14439) malloc: *** vm_allocate(size=235171840) failed (error code=3)
main(14439) malloc: *** error: can't allocate region
main(14439) malloc: *** set a breakpoint in szone_error to debug
terminate called after throwing an instance of 'std::bad_alloc'
My program at the time of crashing uses around 1.8GB of virtual memory. And i use gcc compile to compile.
This is mac pro machine with "Darwin" Operating System". This machine has 8GB of Physical memory and even at the time of failing it shows 3-4 GB of free physical memory and around 14GB of virtual memory. So i do not thing lack of memory is the problem.
The c++ compiler is a 64 bit compiler and it make a 64 bit executable. So memory address is also not a issue.
This machine do successfully run executable written in fortran (not by me) requiring 8GB of memory.
I tried to make a program just to allocate memory till the program crash because lack of memory space. And, this program crash at around 3.5 GB or 1.8 GB depending on the chunk of memory i am allocating at a given time. If i allocate 8KB at a time then it crash at 1.8 GB and if i allocate 8MB at a time than it takes around 3.5 GB before crashing out.
Please note here that for large chunk it goes further which i think is weired.
Also, I have much smaller linux machine on which my code runs fine but become too slow and take long time. But it does not go out of memory. So there does not seems to be any problem with code. Also i used memory leak tool to check that there is no memory leak.
I have no idea why this is happening and have no clue in which direction i should proceed. Please give me hint what could be possibly wrong.
11-07-2008, 10:57 PM #2
- Member Since
- Aug 02, 2005
- 2.6GHz Core i7 15" MacBook Pro - 8GB DDR3 SDRAM - 750GB 7200 RPM HDD - GeForce 650M GT 1GB VRAM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By Redheadsrule13 in forum Apple NotebooksReplies: 4Last Post: 01-11-2013, 07:08 AM
By thuffir in forum OS X - Development and DarwinReplies: 3Last Post: 11-18-2008, 11:30 PM
By djmitch in forum OS X - Apps and GamesReplies: 3Last Post: 06-14-2005, 02:46 PM
By mogwai in forum OS X - Operating SystemReplies: 2Last Post: 05-18-2005, 02:19 AM
By gsx292 in forum OS X - Operating SystemReplies: 3Last Post: 02-09-2004, 02:04 PM