LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Concatenating string and putting in shift register slows computer down

Solved!
Go to solution

Hi all,

 

I was trying to create a record of comms between LabVIEW and an Arduino by concatenating the current message with previous messages and putting it in a shift register.  After a couple of hours the LabVIEW started to crawl.

 

I had a vague idea that you could write to a string indicator without wiping the old contents.  I thought if I could do that there would not be a huge overhead copying an every larger string.  

 

Am I dreaming?

 

Thanks

0 Kudos
Message 1 of 8
(3,291 Views)

Strings act a lot like arrays.  Every time you concatinate to your string, LabVIEW has to allocate more memory.  And when the string gets long, this can take a long time and slow down your system.

 

You really should think about limiting the amount of data is saved in your string.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 8
(3,252 Views)
Solution
Accepted by pgaastra

If you need the whole comm record I would suggest streaming the comms to file.  Make sure you put a boolean in to disable logging.

 

Usually, this is one of those things you only do while debugging.  If so use NI Spy rather than write your own debugger.


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 8
(3,239 Views)

Also, let it run some hours longer and you will receive out-of-memory errors and your application will stop working.

This is well-known issue for ALL programming languages and is created by growing arrays, hence memory consumption, and often referred to by the term "issue caused by memory fragmentation".

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 8
(3,235 Views)

Thanks Jeff,

 

I have never used NI Spy but sounds like the way to go.

0 Kudos
Message 5 of 8
(3,207 Views)

Hard to see the wood for the trees in NI I/O Trace (was NI Spy).  If I need the log I think I'll save the messages to a file (Jeff's other suggestion)

 

Thanks again

0 Kudos
Message 6 of 8
(3,180 Views)

@pgaastra wrote:

Hard to see the wood for the trees in NI I/O Trace (was NI Spy).  If I need the log I think I'll save the messages to a file (Jeff's other suggestion)

 

Thanks again


IO Trace (NI Spy)  There I go dating myself againSmiley Wink  I still sometimes "Dial" a telephone number too.


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 8
(3,174 Views)

Another option is to use an array of strings instead of a single string. This won't prevent the memory filling up eventually, but there is one crucial difference - with a string, LV (and the OS) has to allocate a contiguous block of memory for the string, which can be harder and harder to find as it grows. An array of string will still require the same amount of memory (more, actually - 8 or 12 additional bytes for each string), but that should be fragmented, because it should be represented as an array of pointers to where the actual strings are. Here's the relevant section from the help - http://zone.ni.com/reference/en-XX/help/371361K-01/lvconcepts/how_labview_stores_data_in_memory/


___________________
Try to take over the world!
Message 8 of 8
(3,165 Views)