LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Where is Memory Leak? ( Reading from ULx Card, Saving to MySQL )

Hey, 

I have a problem with my application. For the purposes of this post I've made a simple version of my project ( attached ) which still have it's main issue - memory leak. 

This VI keeps using more and more RAM over time. I've made test over three days with RAM usage logging every half hour and it went from 71 MB to 156 MB so it's about 1MB grow over hour but it isn't a steady growth. Example chronological logs:

106˙236 KB
107˙048 KB
106˙536 KB
100˙588 KB
100˙208 KB
107˙240 KB
108˙700 KB
109˙512 KB
110˙044 KB

Right now I've no idea what causes growth of memory usage.


Technical details: 
 - Data Acquisition Card: Measurement Computing 1608 FS PLUS ( USB )

 - Database: MySQL ( Earlier it was MSSQL 2012 but it also caused some memory leak ( in mssql application ) so we switched to MySQL )

 - Idea of application is to acquire data from card ( when some condition are met ) , save it to TDMS files and log some informations to SQL Database.

Can someone tell where can be the problem?

0 Kudos
Message 1 of 2
(2,739 Views)

I think the problem can be that you write data to the queue faster than you read it. Queues store the data in the memory until you read it, that's why I think this could be the problem.

 

Firsty you should try to set a constant for the "max queue size" for the Obtain queue VI. This can cause that some of the measurement data will be lost, but if the memory leak problem is solved with this, than we can say that the problem is what I wrote down above.

 

This problem with the queue can be solved in two ways:

- You can slow down the acquisition method. Maybe the digital read has some noise problem in change, that it acquires 010101 instead of 000111, which means you call the analog acquisition more times (but I think this problem is solved in the acquisition device itself). Other thing is to read less samples at the Analog Read part if your project enables it. Or make some changes in the digital IO part to call the Analog Read loop less frequently. Again it depends on your project requirements.

 

- Other way is to speed up the dequeueing part. As I can see you always create a TDMS file in every iteration. This slows down this part. You shold open one file in the initialization part and close it just in the end.

 

I hope that this answer will help you.

Message 2 of 2
(2,661 Views)