[Insight-users] Allocate Error
ALBERT Aurélien
aurelien.albert at alyotech.fr
Tue Aug 3 02:55:22 EDT 2010
Hi,
I had the same problem on a project last year.
std::bad_alloc is thrown when the memory allocation failed.
In many cases, allocation failed because there is not enough free memory to allocate.
But sometimes, it's because there is not enough CONTINUOUS free memory.
For example, you can have 5Mb free, but in 5 blocks of 1Mb.
In this case, if you try to allocate 2Mb, std::bad_alloc is thrown.
You are probably in this case if you allocate / free a lot of images and your program crash.
The only way to "defragment" memory is to kill+respawn a process : we did that by :
- launching a process in our application
- allocate memory in this process
- share it with main process
- use it
- free it
- kill the allocator process
This way, there is no more problem of "fragmented" memory.
-------------------------------------------------------------------------------------------------------------------------------------
De : insight-users-bounces at itk.org [mailto:insight-users-bounces at itk.org] De la part de Neil Panjwani
Envoyé : lundi 2 août 2010 22:02
À : insight-users at itk.org
Objet : [Insight-users] Allocate Error
Hi,
I'm new to ITK and I'm trying to work off of an existing project from 2 years ago using ITK version 2.4. The problem I'm currently facing is that whenever an image is created, I get an error running the Allocate() function. Specifically, I get the error:
Unhandled exception ..exe:
Microsoft C++ exception: std::bad_alloc at memory location
The project relies heavily on creating new images and allocating them. How can I fix this error?
Thanks in advance.
- Neil
--
Neil Panjwani
Duke University | B.S.E. 2010
Intramural Research Training Award (IRTA) Fellow
National Institutes of Health | Clinical Center
Bldg. 10, Rm. 1C515
neil.panjwani at nih.gov
Tel: (301) 594-5571
More information about the Insight-users
mailing list