Results 1 to 2 of 2
  1. #1
    Memory allocation fails

    Member Since
    Nov 07, 2008
    Posts
    1
    Memory allocation fails
    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

  2. #2
    Memory allocation fails
    Discerptor's Avatar
    Member Since
    Aug 02, 2005
    Posts
    1,229
    Specs:
    2.6GHz Core i7 15" MacBook Pro - 8GB DDR3 SDRAM - 750GB 7200 RPM HDD - GeForce 650M GT 1GB VRAM
    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?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to find GPU memory allocation.
    By Redheadsrule13 in forum Apple Notebooks
    Replies: 4
    Last Post: 01-11-2013, 06:08 AM
  2. question about objective C memory allocation
    By thuffir in forum OS X - Development and Darwin
    Replies: 3
    Last Post: 11-18-2008, 10:30 PM
  3. OS 9 applications: memory allocation
    By djmitch in forum OS X - Apps and Games
    Replies: 3
    Last Post: 06-14-2005, 01:46 PM
  4. memory allocation to apps
    By mogwai in forum OS X - Operating System
    Replies: 2
    Last Post: 05-18-2005, 01:19 AM
  5. OSX Program Memory Allocation
    By gsx292 in forum OS X - Operating System
    Replies: 3
    Last Post: 02-09-2004, 01:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •