Click to See Complete Forum and Search --> : Memory usage and memory leak


a.rongas
July 29th, 2008, 03:08 AM
Hello,
I have an application that utilizes a frame grabber (a card that gives frames from analog input). A dll using the frame grabber SDK gets frames and puts them to a ring buffer. Other dlls, managed from a container, get these frames and process them.
The issue is that since i process images, i work on 1.5G of memory usage. After 3 days, application crashes (on mallocs...).

Q1. Which is the maximum practical memory utilized from a process? I thought it would be all the system process but it turns out it is 2G theoretical. Practically? Am i capable of utilizing this memory?

Q2. At 1.5G i crash, i am stable, based on the windows task manager for 3-4 days at 1.5G. Is it possible that i have a memory leak somewhere and task manager does not show it? But still.... why in 1.5??

Q3. I do not have access on the code, but i can ask for the rest of the team to use the memory leak detection flags of visual studio and provide me with dll's. If this is the case, can i see, on debugging, where (which dll) memory leak occurs (if it occurs inside the dll's)?

Thank you all and sorry if my questions are huge...
Edit/Delete Message

Zaccheus
July 29th, 2008, 03:36 AM
I think the most important issue to look at first would be how the application detects and handles running out of memory. It should never crash due to memory allocation failing.

Q1. In Windows I think it is theoretically 2GB per process, but in practice it could be less, so your 1.5G makes sense. BTW, Windows will keep a copy of the other process' memory on disk while your application is active.

Q2. Not sure I understand the question. The application runs for days at 1.5GB and then needs more memory?

Q3. Not having the source code is really going to make it hard to find out what is wrong.

PredicateNormative
July 29th, 2008, 04:31 AM
My work is similar to yours, we extract raw stream data from frame grabbers and do some rather complex processing over 14 or 15 stages at about 20fps.

For the moment, the first thing is to look into the point that Zaccheus has raised.

But a second worry is that 1.5GB is a massive amount of memory you are using. It suggests to me there is, at best, a loose approach to memory allocations in your processing chains and, at worst, something seriously wrong - that is assuming you are not buffering all of your outputs for some reason such as building a 3D image out of 2D slices. So the next step is to "audit" your memory allocations, making sure they are all accounted for and appropriately freed.

That aside, with respect to the crash you may well have a heap corruption (possibly caused by a buffer overrun originating from bad pointer arithmetic) that is only showing up when malloc attempts an allocation.