LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

memory increase in regular intervals

Hi, I am trying to run an application having different states in it (Hybrid architecture). But I am finding that at regular intervals, the memory size is increasing by 64KB. The time is also quite periodic. I have checked each and every loop for any memory leaks or any problems but in vain.

Can someone give me any pointers of why this increase in memory is happening.

 

I run each loop once in every 1 sec, but the memory is increasing after every 3 minutes. I tried perfmon to check this graph.

 

Thanks

Sreedhar.

0 Kudos
Message 1 of 15
(4,160 Views)

Sreedhar,

 

 Can you put the code up?

 

Matt

0 Kudos
Message 2 of 15
(4,151 Views)

Hi, Thanks for getting back. Unfortunately, I have the code on a remote network which has no internet connectivity.

 

However, I can try to brief out how my app is functioning:

 

1. There is a low level driver to obtain data from MIL 1553 Card. The driver acquires and 'enqueues' the data into a queue in every 1Sec. This has been independently tested and proved OK.

2. My application (flushes the queue) in the timeout mode and checks for any change in data. This loop runs at every 500ms.

3. If there is a change in data, the application converts the obtained data into a 2D array of string and displays on a UI (data table). The data type obtained after flush is: 1D array of Clusters having 1D array of Clusters having 3 numeric, 1 float and 1, 1D array of numeric values) (I get the top 1D array because i flush a queue)

4. After the data is displayed on the UI, the same data is queued again and after a certain queue size, the data is sent to a log VI (another VI which is launched dynamically in the initial stage) which logs data into the file.

5. Iam opening the file ref only once and keeping a check of the file size, if the size exceeds by 1MB, I am closing the file and re-opening a new file. Each new file is created in a span of 1hr and 30min. I have also checked that this closing and opening of file has nothing to do with the increase in memory. I have tested that part for quite a long period of time.

6. After completion of the logging state, the main app returns to the timeout mode and flushes the data from the queue which the driver has enqueued.

 

Hope I am clear.

 

Thanks

sreedhar.

0 Kudos
Message 3 of 15
(4,141 Views)
The reason they are looking for the code is to see if things are being allocated and de-allocated correctly in the program. Can you tell if the memory is a constant build up or is there some garbage collection has not occurred? Have you tried using the trace programs?
0 Kudos
Message 4 of 15
(4,135 Views)

Yes!! I have used the execution trace tool kit and also the VI profiler. There are no reference leaks and memory loss. The amount of allocation that is happening is also getting freed up. There is however some memory resize (5 to 70 bytes) happening in each loop.

 

Im so sorry about the constraint that I cannot post the code. However I will attempt all the methods that each one of you would recommend and answer you back.

 

cheers

0 Kudos
Message 5 of 15
(4,114 Views)

Here's my 2c worth 

 

Looking at the characteristics of your program, I would personally recommend you look at the timing.

your timeout is every 500ms, if due to some timing issue (the PC is running some other program like a Virus scanner or Outlook that is slowwing it down, in my experience this can affect timing issues quite a bit.

If the queue doen't get flushed what happens?

Is the 2D array out getting larger each time (uninitialised shift register)?

It's not something a simple as the MIL driver session being opened repeatedly but not being closed is it? - The number of times I've seen that with DAQ cards as the cause of a memory leak that builds up by 2bytes or so per run.

 

James

 

 

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 6 of 15
(4,107 Views)
0 Kudos
Message 7 of 15
(4,070 Views)

Sreedhar T wrote:

...But I am finding that at regular intervals, the memory size is increasing by 64KB. The time is also quite periodic. ...

Thanks

Sreedhar.


That sounds like a ref is geting opened and closed repeatedly.

 

Example:

If I open, use and close a VISA ref repeatedly and start the code on Friday afternoon, by Monday I will see more momory used by LV. When i stop LV the memory will drop to where it was when I started.

 

So look for similar situation in your code.

 

If all else fails start throwing away code until the problem goes away. Then look back at the last thing tossed.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 15
(4,053 Views)
Are you overwriting the UI data table when it is updated or is this array continually growing?


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 15
(4,043 Views)

@Ben: Yes, as I am continuously logging the 2D data into a file, I am opening the file ref at the initilization (executes only once) and continuously checking the size. As soon as the file size is greater than 1MB, I am moving the file into an Archive folder by attaching a time stamp to the file name. In the process I am creating a new file and again checking the size. The archive typically is happening at about every 1Hr 30Min, whereas the size is increasing typically at about every 50Min. Each time it is 64KB.

 

@Mark: I am appending the 2D array untill it has reached 1000 elements. Then, I am deleting the first rows and appending new at the bottom. The data scrolls by then on at the rate of every 1 sec. This logic was a bit difficult for me to implement as this runs as many times as my loop iterates. However, I have tried to run this by using dummy data seperately. I saw that the memory increases as long as the 2D array reaches to its peak (1000 elements), then it remains steady. I have tried running it for more than 24 Hrs and it seems to quite stable.

 

I read the following link below and tried using it for a couple of hours. Currently and it appears to be doing good for me too... I have set for an overnight test today, will analyze the results tomorrow and let you all know:

 

https://forums.ni.com/t5/LabVIEW/LV-memory-leak-How-to-use-windows-API-SetProcessWorkingSetSize/m-p/...

 

Cheers

0 Kudos
Message 10 of 15
(4,039 Views)