From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Small program occupying lots of memory

I wrote a small program (attached). It is not a big program, however it is occupying 9.7MB of memory.

Can any one help how to reduce the memory or what is the issue in the program.

 

Thanks

Jack

0 Kudos
Message 1 of 11
(2,724 Views)

How large are those arrays?  That would be the first thing I would look at for being a memory hog.


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 11
(2,719 Views)

Is it possible you have big pictures in your frontpanel?

Also try clean up the wire mess, just a tip.

---

UnCertified LabVIEW Student
Mistakes are for learning, that's why suggestions are always welcome!
0 Kudos
Message 3 of 11
(2,718 Views)

The Y array and circ are  800x800.

0 Kudos
Message 4 of 11
(2,713 Views)

I don't think 800x800 arrays are the problem, the both will take 16kb.

Probably it's an image or some other file.

---

UnCertified LabVIEW Student
Mistakes are for learning, that's why suggestions are always welcome!
0 Kudos
Message 5 of 11
(2,706 Views)

Hi Jack,

 

attach the VI instead of a plain picture of the BD!

 

@Koen:

an "Image" with 800×800 pixels provided as DBL datatype requires 800×800×8 bytes = 5000 KiB in memory. With some overhead (read: "data copy"!) the VI easily needs 9.7MB of RAM...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(2,684 Views)

Right you are Gerd.

Keep in mind that Jack123 mentioned that both arrays ("The Y array and circ are  800x800.") are 800 x 800 with datatype DBL.  A memory footprint of 9,7MB is as expected: 800 x 800 x 8 = 10240000 bytes.   10240000 bytes / 1.024 / 1.024 = 9.765 MB

0 Kudos
Message 7 of 11
(2,672 Views)

Thanks GerdW got juked by Labview compression.

If you make an array with many duplicates its waaaaay smaller.

Next time I'll think first before trying!

---

UnCertified LabVIEW Student
Mistakes are for learning, that's why suggestions are always welcome!
0 Kudos
Message 8 of 11
(2,667 Views)

@Jack123 wrote:

I wrote a small program (attached). It is not a big program, however it is occupying 9.7MB of memory.

Can any one help how to reduce the memory or what is the issue in the program.


If the arrays are 800x800, that sounds about right. Actually I would probably expect more than that.

 

The I32 array will be about 2.5MB (800x800x4) bytes and the DBL array about 5MB (800x800x8, assuming "circ" is also 800x800). Is this a subVI that has the front panel hidden? If the front panel is open, you also have extra data copies in the controls and indicators. There are several coercion dots, forcing additional data copies. How big is "image pix value"? How big is "Phase"? I expect more than 10MB total for this VI! Then we have "image" and "image out"

 

How are you measuring the memory use?

 

To optimize memory use, first you need to clean up the code. Why is "image pix value" control inside the FOR loop? Do you expect it to be modified during the execution of the loop? If you don't, it seems silly to recalculate the min-max on the same array 24 times in a row. A large part of the loop code is loop invariant. (the compiler might be able to move most of it outside the loop, but it is difficult to predict what it will do, especially if debugging is enabled.

 

Keep the front panel of the subVI closed. Disable debugging., etc.

 

Can you attach your VI?

0 Kudos
Message 9 of 11
(2,665 Views)

@altenbach wrote:

@Jack123 wrote:

I wrote a small program (attached). It is not a big program, however it is occupying 9.7MB of memory.

Can any one help how to reduce the memory or what is the issue in the program.


If the arrays are 800x800, that sounds about right. Actually I would probably expect more than that.

 

The I32 array will be about 2.5MB (800x800x4) bytes and the DBL array about 5MB (800x800x8, assuming "circ" is also 800x800). Is this a subVI that has the front panel hidden? If the front panel is open, you also have extra data copies in the controls and indicators. There are several coercion dots, forcing additional data copies. How big is "image pix value"? How big is "Phase"? I expect more than 10MB total for this VI! Then we have "image" and "image out"


Christian, look at the VI again.  Y is a 2D array of doubles, along with circ.  We can't actually tell what the blue 2D array's data type is based on the picture (data type is defined with a constant).

 

 

Are we talking about actual memory (RAM) or the space on disk?  9.7MB makes perfect sense for space on disk since 800*800*8*2 gives us 9.7MB.  Are those controls supposed to hold default values?  If not, empty the arrays (right-click on the front panel controls and choose Data Operations->Empty Array) and then save values as the default.


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 10 of 11
(2,638 Views)