03-01-2006 03:55 AM
03-01-2006 11:30 AM
03-14-2006 10:10 AM
The application I have is this:
One main vi handles the user interface and test prodecure, comprising of 20 tests. The running functions for each test are not particularly intensiven nor are the 6 ro 7 while loops running in parallel. A number of while loops operate in parallel: the least important running every 200ms, the most important at 10ms. The memory properties of this is: Front Panel objects 881K, Block Diagram objects 12962K, Code 4699K, Data 62870K, Total 81413K. In this vi, I have tried to make as many units into subVIs as possible; I use only 1 or 2 arrays, but many local variables.
The second vi operates in the background dealing with communications with an ECU reading CAN messages from a buffer. The most intensive function is a while loop running at 5ms, reading the ECU data, converting it with a subVI, and writing it to a global array, which is read by the main vi.
THE PROBLEM: after long running, the 5ms loop timing cannot be maintained, causing the buffer to overflow as I cannot read quick enough. I only read 1 sample each loop iteration for timing purposes since i have no timestamping of the data and use the loop timing to generate a timebase.
1) The subVI call in the 5ms loop, I dont think is set to subroutine, so that's worth trying. I guess this is a must, whenever it's a function that does not need front panel interaction.
2) At the start of each of the 20 tests, I initialise an array (I reuse the same array in each test) to a large size e.g. 18000x30, which is used to store running test data. Before I initialised it to an empty array. The difference is that to save the data, before, it would constantly create a copy and resize the array, which I thought was the reason for the PROBLEM.
3) I know the memory stats for the main vi are much too large, but i have noticed that if I delete all the array initialisations, the Data becomes 2260K. Is it the initialisation causing the memory increase or is it the use of local variables which causes a separate copy of the same array.
4) With regard to open references, sometimes I have left them open, eg, queue references or vi references, but I am checking to close them down. How much of an issue is it to leave a reference open, and also if I then open the same reference again?
03-14-2006 10:46 AM
03-14-2006 01:53 PM
In addition to johnsold's good suggestions, I'd like to give you a specific tip regarding one of the things you mentioned:
2) At the start of each of the 20 tests, I initialise an array (I reuse the same array in each test) to a large size e.g. 18000x30, which is used to store running test data. Before I initialised it to an empty array. The difference is that to save the data, before, it would constantly create a copy and resize the array, which I thought was the reason for the PROBLEM.
Because arrays require contiguous blocks of memory, and because LV manages allocation/deallocation auto-magically, there are times that performance degrades as you re-run your LV program over and over. A colleague & I discovered a neat technique that was a lifesaver in our app. We had an RT app where the RT controller would completely crash after about 3-5 runs due to this memory issue. Look at my post in this thread for a solution.