New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Memory allocation fails


Post Reply New Thread Subscribe

 
Thread Tools
skvikas

 
Member Since: Nov 07, 2008
Posts: 1
skvikas is on a distinguished road

skvikas is offline
Hi All,
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'
what(): St9bad_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.

Thanks,
Shailendra
QUOTE Thanks
Discerptor

 
Discerptor's Avatar
 
Member Since: Aug 02, 2005
Posts: 1,229
Discerptor is a name known to allDiscerptor is a name known to allDiscerptor is a name known to allDiscerptor is a name known to allDiscerptor is a name known to allDiscerptor is a name known to allDiscerptor is a name known to all
Mac Specs: 2.6GHz Core i7 15" MacBook Pro - 8GB DDR3 SDRAM - 750GB 7200 RPM HDD - GeForce 650M GT 1GB VRAM

Discerptor is offline
Quote:
Originally Posted by skvikas View Post
Hi All,
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'
what(): St9bad_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.

Thanks,
Shailendra
If you could upload your code somewhere, that would be very helpful. Also describe what options you're using when you call g++ to compile your code. Additionally, what version of the GNU C Compiler are you using on Linux, and which version is in your OS X install?
QUOTE Thanks

Post Reply New Thread Subscribe


« DASHCODE!!!!!!! help me with stack layout | Installing XCode 2.4.1 on os 10.5 »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Will I see an improvement upgrading to 4gb of RAM over 2gb miketrue Apple Notebooks 9 08-22-2008 07:55 AM
My PowerMac G5 is acting screwy! aedolch OS X - Operating System 5 08-01-2008 07:12 PM
Why Apple recommends matched pair memory bigbadandugly Apple Desktops 5 04-08-2006 03:41 PM
OS 9 applications: memory allocation djmitch OS X - Apps and Games 3 06-14-2005 02:46 PM
OSX Program Memory Allocation gsx292 OS X - Operating System 3 02-09-2004 02:04 PM

All times are GMT -4. The time now is 09:45 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?