Memory allocation problem in C++ (memory Leak)
-
I am using Visual C (win32 Console Application) for feature extraction program. In my project I am extracting features from the trained images. Features aren in form of structures. Strcuture has 4 DOUBLE data items and 1 INT array of size 128. So this means one feature from the image. On average one image may generate from 500-1000 features. I am using dynamic memory allocation to store the structures for every trained image. I am using 800 images for training. This means huge amount of memory will be consumed to keep these features iN RAM. Now problem is that after training of 740 images I am getting error of memory leak i.e. insufficient memory to allocate. I have tried every possible way to avoid it but can't. So please tell me how i can overcome this issue. I will be really grateful.
-
I am using Visual C (win32 Console Application) for feature extraction program. In my project I am extracting features from the trained images. Features aren in form of structures. Strcuture has 4 DOUBLE data items and 1 INT array of size 128. So this means one feature from the image. On average one image may generate from 500-1000 features. I am using dynamic memory allocation to store the structures for every trained image. I am using 800 images for training. This means huge amount of memory will be consumed to keep these features iN RAM. Now problem is that after training of 740 images I am getting error of memory leak i.e. insufficient memory to allocate. I have tried every possible way to avoid it but can't. So please tell me how i can overcome this issue. I will be really grateful.
Maximum of 2GB memory can be given to a process at a time (in 32-bit OS), once it goes beyond that limit, the program will not work. Now first check if you want all these 800 immages to be in memory at a time, if no then see that you are freeing up the unnecesssary memory. If you are facing difficulty in tracing that you are freeing up the memory correctly or not then you can use any memory leak detection tool to verify that. One of popular freeware is LeakDiag. Hope this will help you. :)
Thanks, Anand.