LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Some thoughts on memory allocation optimization for arrays of strings

Hi everybody,
 
trying to optimize the memory usage of my program...
I need to assemble an array of strings (variable lengths); for this I intend to use the "Initialize Array" function in order to avoid too many accesses to the memory manager. So far so good, but if I see that right, the manager is invoked again, if I try to replace a certain element within this array, because the string length is adjusted. Is that right so far?
If it is; would the following procedure improve the behaviour?
1.) Init an array of strings with the appropriate number of elements (string of maximum expected length).
2.) Replace array elements. This should cause the memory manager "only" to deallocate the unused memory; would be faster than allocating, wouldn't it?
 
If my assumptions are right.... do you think there will be a significant gain in execution speed? Smiley Surprised
 
 
 
Cheers
Oli
0 Kudos
Message 1 of 6
(2,709 Views)

If performance is an issue, arrays of strings should be avoided like the plague.

Your theory is about allocating large string and work within that string.

There are a couple of string operators that will operate like the array operations.

AS long as you don't brach the wire you should be in good shape.

If you code up a bench marking VI, you should see major differences in performance.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 6
(2,700 Views)
LabVIEW does not have fixed lenght strings. Maybe you could do all operations on a 2D U8 array "in place".
Message 3 of 6
(2,698 Views)

Hi Ben, hi altenbach,

thank you for the information, right now, I consider using 2D arrays of U8 instead of strings.

 

Happy Halloween!

Oli

0 Kudos
Message 4 of 6
(2,661 Views)

Just for your reference: A while ago, Shane suggest the feature of fixed length strings:

http://forums.ni.com/ni/board/message?board.id=features&message.id=67#M67

could be useful!

 

0 Kudos
Message 5 of 6
(2,655 Views)


@altenbach wrote:
Maybe you could do all operations on a 2D U8 array "in place".
Altenbach,
 
Can you please explain the above operation with a small example? Smiley Happy
 
I m not at all able to grab the concept of using a 2D U8 array for a Str array. Smiley Sad I ve not coded like this till now, so I m not quite clear about what you mean.
 
Thanks in advance.
- Partha ( CLD until Oct 2027 🙂 )
0 Kudos
Message 6 of 6
(2,645 Views)