LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW does not exit in executable

I could understand using a time delay in a While Loop that DOESN'T contain an Event Structure so as to limit the number of loops it can process per second, but I don't see how this can help when using an Event Structure inside a While Loop since the loop is only executed when an Event is Triggered and in my application that is not very often.

 

Ah I just read your other e-mail.  Don't you mean CPU usage rather than Memory usage.  Like I said above this wont help when using an Event Structure inside a While Loop since CPU usage will be 0% when no Events are being processed.

 

Using the Time delay in a While Loop only affects the CPU usage and not the Memory usage.

 

Chris

0 Kudos
Message 11 of 19
(1,825 Views)

Ya thats my mistake. Can you post any other Screen shots that explains the functionlity of the code. Have you checked the CPU usage of your system while running the code?

 

Smiley Wink

-----

The best solution is the one you find it by yourself
0 Kudos
Message 12 of 19
(1,819 Views)

Well its pretty huge so I don't think I can post the code.

It really is just a simple State Machine and it doesn't do anything complicated.  It reads and writes to a couple of databases now and again and prints a couple of labels, and it's all controlled by the user through the Main GUI (attached), so the CPU usage is practically zero most of the time.

 

Even for the worse case event when I Sync all the Folders and Databases the CPU usage only goes up to 50% for a few seconds.

 

No I think there is something else that is causing the application to not shutdown properly - an open reference to a VI or an ActiveX method or something, but I don't know how I can verify this?

 

Chris

0 Kudos
Message 13 of 19
(1,810 Views)

Are you closing the vi reference properly when you stop the VI?...

 

 

-----

The best solution is the one you find it by yourself
0 Kudos
Message 14 of 19
(1,805 Views)

Well I've tried three completely independent methods (JKI's, MGI's and my own) and none of them work, so I don't think all three methods could be wrong, which leads to me suspect that the problem lies elsewhere, but godness knows where Smiley Sad

 

Chris

0 Kudos
Message 15 of 19
(1,796 Views)

Well I found out where all the memory was being consumed -  it occured when I did a couple of SQL queries on the database using the NI connectivity toolkit.

 

On my development machine (not the exe application), when I ran the main application LabVIEW consumed about 120MB of memory, but when I ran the code below it jumped to about 340MB!! and did NOT release the memory even though I used the Tools Free Object VI after each SQL Query.  The only way to recover the memory was to completely Quit LabVIEW.

 

As you can see below I open a connection to the database and then do four SQL queries in series, and it is the third one that returns a 2D array (23,000x8) of strings that hogs all the memory.

 

So......

a) How come this one query requires around 200MB of memory to execute when the VI below just converts the Variant data from the database (which is all strings anyway) to a 2D string array which is then written to a standard text file 2MB in size.

 

b) Why isn't the memory released when I either free the SQL Query or close the connection to the database. 

 Database Query.jpg

0 Kudos
Message 16 of 19
(1,774 Views)

Well things just got a little weirder.  It seems that if I minimise then restore my main GUI screen the memory usage of the application falls dramatically from 250MB down to 3MB - what the hell Smiley Surprised

 

So it seems that after each sync with the database I will have to minimise then restore my main GUI to recover my memory - yuk!!

 

Can anyone explain what is going on and why do I get this behaviour?

 

Chris

 

0 Kudos
Message 17 of 19
(1,754 Views)

Check out this thread.  minimize window vs memory usage

 

Also LV memory leak - How to use windows API SetProcessWorkingSetSize (from Kernel32.dll)

 

I did a search on "minimize window memory" and there are other messages threads with similar issues.

0 Kudos
Message 18 of 19
(1,748 Views)

Well that discussion opened a big can of worms didn't it - thanks for that.

OK this pretty much explains most of the issues I've been seeing, EXCEPT the huge increase in memory usage from 70MB to 250MB when I do my SQL Query, but I guess I can leave that for another day.

 

Thanks once again for that link - Chris

0 Kudos
Message 19 of 19
(1,734 Views)