LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

very high memory consumption > 1GB!

Solved!
Go to solution

Hello all.  I've got two deployed applications, both compiled under CVI 2015.  These apps have been running for over 1 year, pretty stable.  Every once in a while, I see some mysterious crashes, but rarely.

 

So yesterday I saw one of these crashes and decided to investigate more.  Turns out that one of the apps was consuming 900MB of memory!  It climbed to 1.3GB when I let Windows force close it.

 

Now the other application I mentioned above seems to be consuming this much memory as well.  These two apps share maybe 2% of their codebases: merely some logging, error handling libraries, general UI elements.  They have radically different requirements and core functionality.

 

And yet both, in steady state, after maybe 96 hours of continuous operation, are chewing up nearly 1GB of memory!

 

So there's clearly a memory leak here somewhere.  I ran the execution profiler but didn't see any big issues.

 

Are there any known issues with the 2015 runtime?

 

Any hints as to what I can look at for memory cleanup / optimization?

0 Kudos
Message 1 of 14
(4,876 Views)

There are many ways to look for memory leaks. Main one is to use Valgrind, but I'm not sure if it runs on Windows. A simpler alternative is to use a special malloc/free library that logs the calls into a file for later analysis. I've used one of those with CVI in the past.

0 Kudos
Message 2 of 14
(4,858 Views)

Is the execution profiler the correct tool for this? Wouldn't the resource tracker be the better tool to use?

 

Are you using any add-on libraries/tool kits? I have run into this problem with the CVI Vision library, many functions will cause memory to be allocated, and you have to remember to call the correct function to free it. But there is no notification to the CVI resource tracking tool, all that happens is that memory gets chewed up, and you cannot see what is causing the leak.

0 Kudos
Message 3 of 14
(4,826 Views)

Some years ago I successfully used LeakDiag software to discover and fix a memory leak in my CVI application.

I followed the suggestion described here

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 4 of 14
(4,811 Views)

Unfortunately, I can't find LeakDiag anywhere.  Microsoft must have shut down their public FTP.

 

I found a page for a tool called Visual Leak Detector, but it appears to be a plugin for Visual Studio Debugger.

 

I did a survey of my two projects and both do have one thing in common: a good number of dangling malloc calls.  Uh-oh!

 

Both also use quite a few of the CVI libraries, like toolbox, RS232, TCP, etc.

0 Kudos
Message 5 of 14
(4,778 Views)

I downloaded it some months ago and I can share (if it is allowed by the license and if I find a way).

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
Message 6 of 14
(4,775 Views)

Yes please!  I think you can simply upload it here.  Attachments button in the Reply dialog.  Probably have to zip it first.

0 Kudos
Message 7 of 14
(4,769 Views)

I hope than you can download the attachment

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
Message 8 of 14
(4,767 Views)

Bummer, I get an error during install on my 64bit PC.

 

The files all seem to be installed though and the EXE does indeed open.  However, I'm unable to CTRL click different memory allocators and the Log button doesn't depress.

 

Oh well.  The old-fashioned way, I suppose.

 

I really am beginning to suspect my usage of malloc so much inside functions without freeing elsewhere.  As I understand now, these are literal strings that just go on existing for the duration of the run time.

0 Kudos
Message 9 of 14
(4,763 Views)
Solution
Accepted by ElectroLund

Electro,

 

Why don't you use CVI's resource tracking?

https://decibel.ni.com/content/docs/DOC-45564

If it's malloc without free, resource tracker will point out where they are.

Message 10 of 14
(4,737 Views)