LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with memory usage when loading jpeg files into array

Can anyone help me understand what is going on here?

 

"Memory1.PNG" contains the VI in question. I tried to use tbob's answer on this thread to load images into the picture array, "Slides". The folder "Demo Slides" contains 672 jpeg files. The total size of the folder is ~45 MB.

 

"Memory2.PNG" depicts, using Task Manager, how memory usage changes on different events. Running Untitled 1.vi causes an immediate jump that stays constant till the end of the program upon which is a second, huge jump! Then if I hit "Save" on Untitled 1.vi (at any point) after the program has stopped running, some of the memory seems to be deallocated. Finally, only after complete closing LabVIEW entirely, is the remainder of the memory usage freed.

 

"Memory3.PNG" shows the Profile Buffer Allocations results.

 

New to LabVIEW. First time posting. Any and all criticism is welcome! Thank you!

Download All
0 Kudos
Message 1 of 5
(2,523 Views)

Hi mmkay,

 

The folder "Demo Slides" contains 672 jpeg files. The total size of the folder is ~45 MB.

Ok, there are nearly 700 JPG images.

In a folder of ~45MB filesize.

Usually JPG compresses images with a ratio of ~10: this means those 45MB will uncompress to ~450MB in memory.

Your 3rd image shows the VI is using ~670MB of ram which seems reasonable…

 

Finally, only after complete closing LabVIEW entirely, is the remainder of the memory usage freed.

LabVIEW will handle memory allocations on its own. It will keep memory buffers as long as (possibly) needed.

It will free memory when you flush VIs from memory…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 5
(2,518 Views)

Thanks for the reply!

 

Yes, both of those points make sense to me. But why does the memory jump at the end of the program? Why does some of the memory free up after saving the VI? Is there a way to automatically gain that bit of memory back before the program ends instead of having to manually save the VI after it ends?

 

Also, is there a better image format that does not take up as much space when uncompressed or is it possible to load the images into the picture array without uncompressing them first?

 

Memory2.PNG

0 Kudos
Message 3 of 5
(2,504 Views)

Hi mmkay,

 

But why does the memory jump at the end of the program?

Because the data in the shift register is copied to the "Slider" indicator.

Each indicator keeps its own copy of the data needing also memory for that copy…

 

is there a better image format that does not take up as much space when uncompressed

No.

Uncompressed data is uncompressed data, no matter how they are saved on disc…

 

 is it possible to load the images into the picture array without uncompressing them first?

No.

The picture indicator just takes uncompressed data.

 

To save memory you could load (and uncompress) only those data that are currently displayed.

It's a tradeoff between memory usage and execution speed:

- keeping all images in memory makes your program react faster, but takes up a lot of memory.

- loading the images just when they are needed uses (a lot) less memory, but executes noticable slower.

 

Ok, just an idea for a 3rd option:

- Load all JPG files as "binary" string data

- Use some function to uncompress those binary data when needed: there is no built-in function in LabVIEW to do so. You might use some Windows .Net functions, or create your own JPG "in memory" decompression routine.

That would allow you to read that ~45MB data into memory (use less memory than uncompressed data) and uncompress them rather fast when needed (avoiding file access times) - with much more programming overhead…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(2,496 Views)

The third option you presented sounds interesting and way above my skills in programming.

 

Maybe I should start a new thread, but the real goal is to load a PDF page/ PPT slide embedded in a LV FP without any menu bars from Adobe Reader/Powerpoint displayed, basically no user interaction with the pdf page/slide allowed.

 

From other posts I've seen on this forum and several of my failed attempts, it seems ActiveX is the only option to try this but seems impossible to use to embed without menu bars popping up.

 

So instead I'm running an .exe that saves ppt slides as images and using the picture array I showed. 

 

Thanks for your help!

 

 

0 Kudos
Message 5 of 5
(2,476 Views)