AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Memory leak issue

The forum is to discuss topics related to different areas of image processing and computer vision.

Memory leak issue

Postby snbc2017 » Fri Oct 06, 2017 12:37 pm

I'm new to aforge.net so please excuse for layman's questions.
Here is one: is memory leak somehow linked with video source resolution, i.e. if I take measures with disposing images while putting frame into picture Box did I prevent memory leak on any machine with any video source.
Now, when I check ram use in processes tab in windows task manager, my program (connected with web camera) is relatively stable and does not consume too much ram.
On the other hand, when my program is connected with source of 768x576 memory leak is detected and program eventually crashes.

Enclosed is my code with dispose of image (just to make sure it is correct)

Image oldImage = pctBoxVideo.Image;
Bitmap bitmapXYZ = eventArgs.Frame.Clone() as Bitmap;
pctBoxVideo.Image = bitmapXYZ;
if (oldImage != null)
oldImage.Dispose();

Any thoughts?
snbc2017
 
Posts: 11
Joined: Tue Sep 19, 2017 10:05 am

Re: Memory leak issue

Postby andrew.kirillov » Fri Oct 06, 2017 12:45 pm

The way you dispose memory looks fine (if there are no exceptions, etc.). Are you sure you dispose everything else?

Some time ago I used to use ANT performance/memory profiler. It can be useful to find source of leaks. Try it, it is free for certain number of days.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Memory leak issue

Postby snbc2017 » Fri Oct 06, 2017 12:51 pm

What "else " are You referring to?
RAM counter in windows performance tool is pretty stable...

Anyway, thanks for the link, I'll try it out.
snbc2017
 
Posts: 11
Joined: Tue Sep 19, 2017 10:05 am

Re: Memory leak issue

Postby andrew.kirillov » Fri Oct 06, 2017 1:04 pm

Getting confused. You say:
snbc2017 wrote:RAM counter in windows performance tool is pretty stable...

But before you said:
snbc2017 wrote:when my program is connected with source of 768x576 memory leak is detected and program eventually crashes.


So now the question - Do you have memory leak or no? And if the memory usage is stable - Are you sure the crash is not caused by something else? What does the exception say?
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Memory leak issue

Postby snbc2017 » Fri Oct 06, 2017 1:19 pm

Sorry for being confusing.

When I say: when my program is connected with source of 768x576 memory leak is detected and program eventually crashes,
I actually mean this is happening on another machine connected with 768x576 source and executing my program.
Problem is happening on another machine, where large jump of memory use is reported when my program starts.

BTW, I did an analysis of my code and attached is the result. Please have a look.

Any thoughts?
Attachments
Capture.JPG
profiling results
Capture.JPG (182.66 KiB) Viewed 21833 times
snbc2017
 
Posts: 11
Joined: Tue Sep 19, 2017 10:05 am

Re: Memory leak issue

Postby snbc2017 » Fri Oct 06, 2017 3:04 pm

Another layman's question: can memory leak (potentially caused by aforge) can be linked with graphic card or any other hw?
snbc2017
 
Posts: 11
Joined: Tue Sep 19, 2017 10:05 am

Re: Memory leak issue

Postby andrew.kirillov » Sun Oct 08, 2017 7:20 am

snbc2017 wrote:potentially caused by aforge

Prove it first ;) I would say: "most likely caused by your code" :D

snbc2017 wrote:linked with graphic card or any other hw?

How?
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Memory leak issue

Postby snbc2017 » Mon Oct 09, 2017 10:09 am

I'm facing strange situation now, my code works fine on PC but crashes on tablet after ~2 min. It got up to 450 MB RAM and rising...

Tablet has Windows 10 Enterprise CBB OS.
snbc2017
 
Posts: 11
Joined: Tue Sep 19, 2017 10:05 am

Re: Memory leak issue

Postby snbc2017 » Mon Oct 09, 2017 10:30 am

Is Aforge compatible with Windows 10?
snbc2017
 
Posts: 11
Joined: Tue Sep 19, 2017 10:05 am

Re: Memory leak issue

Postby andrew.kirillov » Mon Oct 09, 2017 11:36 am

snbc2017 wrote:Is Aforge compatible with Windows 10?

Not sure what is meant. AForge.NET Framework does not really care about version of the OS as long as it runs .NET Framework.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK



Next

Return to Image Processing and Computer Vision