LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to analyses what takes memory

Hi,

I have a library with several functions written in labview and compiled into shared dll. Library provides functions to be used in test cases for Production (init, write, read, change, deint, etc). In init function some files are created, connections are established, and some functional globals are created to pass some data between functions.

This library is used at the end in TestStand. I test it first in CVI.

When I start prepared in CVI interface, it takes at start about 55MB. When I hit init for the first time it increases ~10MB. Deinit frees only some kB. Another init adds ~1 - 2MB, and every another init adds ~1-2MB. It seems like some memory is not released. That is not a problem at a test phase, but Production does not do restarts, they just run it on and on, and suddenly they might face a lack of memory.

There are several global variables passed via shift registers, but there should be always the same part of memory used. I read into internal structure xml file that is of size about 400kB, but even if it is read at every init it should be overwritten.

However how to deallocate place for such global.

 

I was trying to use DesktopExecutionTraceTolkit, but I am unable to analyze 400k lines.

 

Is there any other way to analyze what takes the memory, and what keeps it after vi ends?

0 Kudos
Message 1 of 3
(2,906 Views)

Hello Slawomir,

 

I have a couple of suggestions for you.

 

1. It's a good idea to try out the LabVIEW function called " Request Dealocation ". Calling this function will analyze the LabVIEW Runtime and all of the space used by the application, it will localize places that have an option for safe resource deallocation and it will free up the memory. Knowing that you should put this function in the function that deinitializes your functionality. Overusing "Request Dealocation" can lead you to loss in execution speed of code.

 

2. It is also usefull to force LabVIEW to operate in the same place in the memory using In Place Element Structure. With this the compiler will understand that you want to perform some operations in the same place of the memory, without creating a new buffer.

 

3. Desktop Execution Trace Toolkit allows to filter out the views of lines and with this option you are able to see ex. only memory allocations and dealocations. To do this you need to right click on your trace, go to configuration and choose to view only memory allocation (you can use threshold there).

 

Please let me know if any of those suggestions help, Piotr

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
0 Kudos
Message 2 of 3
(2,890 Views)

Hi Piotr,

thank you for hints.

I used function "request deallocation" before, but it gave not any better results.

Filtering result from Desktop Execution Trace Tolkit gave me still klines to be analysed. It is impossible.


I have never used In Place Element structure, but I can check if it can bring some positive results.

 

As a clarification:

INIT function reads some files (and close them after reading) and stores some of this info in functional globals (in registers) - ini file, xml file, log file. It also establish a connections to targets. This refnums are the only ones that are not closed until DEINIT funciton is used. Deinit function mailny closes the connections. I made a mistake in my first post. DEINIT function does not free any memory, it just takes only some kB.

 

I made some tests.

I removed reading of xml file. The consumption of memory decreased a lot as expected. But still memory was allocated and not freed in every start.

I removed then almost all functional globals (but one responsible for holding of refnums to targets), but still some kB was taken and not released.

 

I dont really understand whay the memory that should be self deallocated, is not. I write to some registers, and when i write again, it seems like some other components are created in memory but I still talk to the same register.

 

Or maybe there is a problem in CVI environment? It could not be, that the momory is not released when vi finishes execution.

0 Kudos
Message 3 of 3
(2,838 Views)