LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

memory problem using visa serial functions in my vi

The last few days i created an application that reads data from one of serial ports (contactless card reader). Today i noticed that my application had crashed and Windows had displayed a message that my system was low on virtual memory. I reset the system and i re-run the application, having the task manager opened. I noticed that the memory usage of my exe was taking more and more memory (starting from 21.520KB) as the seconds went by. In 5 minutes my app was using 25Mbytes! What i do in my application exactly, is opening the serial port  then i enter the main while-loop, then every 2 seconds i read from the  serial and write them to a tag.
I have used standard visa serial functions of Labview. When I trace my application and simultaneously run TASKManager of windows to see the memory, I saw that after running every Visa function memory usage goes up!!!
what must I do? Please help me to overcome this problem.
Thanks,
M.Naghipourfar
0 Kudos
Message 1 of 6
(2,858 Views)

What do you mean by "write to a tag"?

You are probably using Concatenate Strings in your loop. This function needs to allocate memory each time and if your string is big, it will take a lot of memory. You should probably initialize a large array or a string before entering the loop and use Replace Array Subset or Replace Substring to replace the appropiate part. Also, if your program runs for a long time, you should periodically save the data and clear your buffer.

If this didn't help, you should post the relevant piece of code.


___________________
Try to take over the world!
0 Kudos
Message 2 of 6
(2,857 Views)
        At first, Please try "Serial Communication.vi" example of LabView, connect a known serial device  to a COM port, send command and read from it in a while loop. Simultaneously run TaskManager of windows and see what happend to the memory usage of Labview in process list. If the memory didn't goes up tell me.
Mostafa
0 Kudos
Message 3 of 6
(2,853 Views)

Trust me, people use serial communication with LV all the time without losing memory. I can't check the example at the moment, but If it had a problem someone would have caught on to it by now. In any case, even if using the serial VIs causes the memory usage to go up, it shouldn't be dramatic, definitely not enough to crash the application and consume all memory.

Like I said, post your code (there is an attachment field when you write your message and you can save all your files into a single file by opening the main VI and selecting File>>Save with Options>>Development Distribution) and we will probably be able to find your problem.

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
0 Kudos
Message 4 of 6
(2,835 Views)

tst:  A tag is a name associated with an endpoint device commonly used in DSC and SCADA systems.  It might be a temperature guage or a valve controller or such.

Naghi:  sounds like you are holding all of your comm strings together in a large string or array, and it builds with time consuming memory.  You should empty the array or string after each time you send it.  Post your code so we can look at it.
- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 6
(2,826 Views)

Thanks, tbob.

Although not a heavy user of the DSC module or the tag engine, I do know what a DSC tag is. I just wanted to make sure he tells us what he means by it, because it might be pertinent.


___________________
Try to take over the world!
0 Kudos
Message 6 of 6
(2,821 Views)