<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Freeing memory when loading large binary files into memory in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/966355#M433173</link>
    <description>&lt;P&gt;Jason,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a similar application where I would like to view a section of data from a large file however I am having some trouble with it.&amp;nbsp;&amp;nbsp; I was trying to use the set position vi to set a marker and then read in the data from that point but I can not get it to work in real time.&amp;nbsp; How do you sift through the file on the disk?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Mon, 17 Aug 2009 20:08:23 GMT</pubDate>
    <dc:creator>Humada33</dc:creator>
    <dc:date>2009-08-17T20:08:23Z</dc:date>
    <item>
      <title>Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/955709#M428487</link>
      <description>&lt;P&gt;I am loading a 200 MB binary file into an array of clusters (each cluster contains 2 U32s, 1 single, 1-D array of U16s, and a 1-D array of singles) to allow users to go back through data that has been collected.&amp;nbsp; However, I see massive amounts of memory being used and I don't exactly know why it isn't being freed.&lt;BR /&gt;&lt;BR /&gt;I ran some tests with just the data loader to try and reduce the memory usage of my application.&amp;nbsp; In the first test I do not output the array to an indicator; however, I need the indicator because my loader is a subVI and I need to pass the loaded data back to the main application.&amp;nbsp; I tried to use a reference to the array but that ended up using more memory overall (which I also don't understand).&lt;BR /&gt;&lt;BR /&gt;I used the PF Usage in Windows Task Manager to collect these numbers. The LabVIEW profiler shows my VI using 210392 KB in the Max Bytes field for the second run below.&amp;nbsp; Subsequent runs show double that; I suspect this due to the pre-allocated array being copied into the already filled indicator.&lt;BR /&gt;&lt;BR /&gt;The same data being loaded via the reference shows 674020 KB in the Max Bytes field!&amp;nbsp; I definitely wasn't expecting that.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;---------------------&lt;BR /&gt;&lt;BR /&gt;without output array to indicator&lt;BR /&gt;&lt;BR /&gt;start: 907 MB&lt;BR /&gt;end: 1.09 GB = 1116 MB&lt;BR /&gt;&lt;BR /&gt;diff = 209 MB&amp;nbsp;&amp;nbsp; (as expected since there is no indicator)&lt;BR /&gt;&lt;BR /&gt;----------------------&lt;BR /&gt;With output array to indicator&lt;BR /&gt;&lt;BR /&gt;start: 890 MB&lt;BR /&gt;end: 1.28 GB = 1310 MB&lt;BR /&gt;&lt;BR /&gt;diff = 420 MB&lt;BR /&gt;&lt;BR /&gt;---------------------&lt;BR /&gt;&lt;BR /&gt;Pass a reference to the loader and have indicator in the main app&lt;BR /&gt;&lt;BR /&gt;start: 1.04 GB&lt;BR /&gt;end: 1.52 GB&lt;BR /&gt;&lt;BR /&gt;diff = 491 MB&lt;BR /&gt;&lt;BR /&gt;----------------------&lt;BR /&gt;&lt;BR /&gt;I added the Request Deallocation VI per some suggestions I've read online but that does not do anything in all these cases.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I figured pre-allocating the array in the loader and then replacing each element in the array would help with the load time:&amp;nbsp; all the required memory is set aside before I start throwing data into memory.&amp;nbsp; However, I end up with 2x the amount of memory being used as I expected and even more if I use a reference to the original array and remove indicator in the loader.&amp;nbsp; How come?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-dennis. &lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2009 22:58:30 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/955709#M428487</guid>
      <dc:creator>dwj314</dc:creator>
      <dc:date>2009-07-30T22:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/955796#M428522</link>
      <description>Is there any reason you are loading the entire file at once? &amp;nbsp;With the structure you describe, it seems unlikely a user would need to see all 200MB of data at the same time. &amp;nbsp;With a binary file, it should be easy to write a subVI that could pull just the subsets of data the user needed at that time.&amp;nbsp;</description>
      <pubDate>Fri, 31 Jul 2009 04:35:53 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/955796#M428522</guid>
      <dc:creator>Jason_P</dc:creator>
      <dc:date>2009-07-31T04:35:53Z</dc:date>
    </item>
    <item>
      <title>Re: Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956226#M428716</link>
      <description>&lt;P&gt;Hi Dennis,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, I am not sure why you are dumping the binary file to an array of clusters? Are you searching by clusters? Why are you not searching the file itself for this information. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the massive memory usage, try initializing the array before you add any of the clusters to it. Also are you passing this array through any tunnels? This could create a copy of your data. Are you splitting the array data path any where? &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The deallocate memory vi only works within subvi's after they&amp;nbsp;are done executing. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards, &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2009 15:10:41 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956226#M428716</guid>
      <dc:creator>Andrew_E</dc:creator>
      <dc:date>2009-07-31T15:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956237#M428722</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;dwj314 wrote: &lt;BR /&gt;&lt;P&gt;I am loading a 200 MB binary file into an array of clusters ...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;---------------------&lt;BR /&gt;&lt;BR /&gt;without output array to indicator&lt;BR /&gt;&lt;BR /&gt;start: 907 MB&lt;BR /&gt;end: 1.09 GB = 1116 MB&lt;BR /&gt;&lt;BR /&gt;diff = 209 MB&amp;nbsp;&amp;nbsp; (as expected since there is no indicator)&lt;BR /&gt;&lt;BR /&gt;----------------------&lt;BR /&gt;With output array to indicator&lt;BR /&gt;&lt;BR /&gt;start: 890 MB&lt;BR /&gt;end: 1.28 GB = 1310 MB&lt;BR /&gt;&lt;BR /&gt;diff = 420 MB&lt;BR /&gt;&lt;BR /&gt;---------------------&lt;BR /&gt;&lt;BR /&gt;Pass a reference to the loader and have indicator in the main app&lt;BR /&gt;&lt;BR /&gt;start: 1.04 GB&lt;BR /&gt;end: 1.52 GB&lt;BR /&gt;&lt;BR /&gt;diff = 491 MB&lt;BR /&gt;&lt;BR /&gt;----------------------&lt;BR /&gt;&lt;BR /&gt;I added the Request Deallocation VI per some suggestions I've read online but that does not do anything in all these cases.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I figured pre-allocating the array in the loader and then replacing each element in the array would help with the load time:&amp;nbsp; all the required memory is set aside before I start throwing data into memory.&amp;nbsp; However, I end up with 2x the amount of memory being used as I expected and even more if I use a reference to the original array and remove indicator in the loader.&amp;nbsp; How come?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-dennis. &lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The extra data with the indicator form would show-up if you had the FP of the sub-VI open. LV has to keep a copy for the indicator so you can look at it while watching it in execution hightlight on the next iteration etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please &lt;A href="http://forums.ni.com/ni/board/message?board.id=170&amp;amp;view=by_date_ascending&amp;amp;message.id=191864#M191864" target="_self"&gt;review the "Clear as Mud" thread&lt;/A&gt; for a mind-boggling explation of when and how buffers ca be re-used in sub-VIs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2009 15:27:23 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956237#M428722</guid>
      <dc:creator>Ben</dc:creator>
      <dc:date>2009-07-31T15:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956309#M428748</link>
      <description>&lt;P&gt;The data ends up being played back like video -- the saved data is fed back into the displays so the user can review the data; there they have control over the playback speed, direction (forward/backward), and can use a scrub bar to jump around within the data. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's two reasons for loading the entire file into memory: the saved files are often archived to the network and then reviewed later (days or weeks later) and I have a tagging system in place during data collection that lets the user jump back into saved positions during playback.&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2009 17:11:41 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956309#M428748</guid>
      <dc:creator>dwj314</dc:creator>
      <dc:date>2009-07-31T17:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956310#M428749</link>
      <description>&lt;P&gt;Hey Ben-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was getting the same results with the sub-VI closd; I ran across that "Clear as Mud" thread while researching before posting my question which was why I was still baffled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-dennis. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2009 17:14:40 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956310#M428749</guid>
      <dc:creator>dwj314</dc:creator>
      <dc:date>2009-07-31T17:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956313#M428750</link>
      <description>&lt;P&gt;I put some more details of what I am doing with this file in the reply to Jason P. above: basically, the data in the file is a time-based data stream.&amp;nbsp; I load it into an array so I can index into it quickly during review -- either by using a tag that was created when it was recorded or with a scrub bar (like in video editing).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the examples I posted, I don't have any cases or tunnels.&amp;nbsp; I pulled everything out to make sure of that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the memory usage of my main application way down since posting this (I did have a tunnel in there).&amp;nbsp; I was still seeing this extra usage that didn't make sense to me so I put the question out there. &lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2009 17:19:05 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956313#M428750</guid>
      <dc:creator>dwj314</dc:creator>
      <dc:date>2009-07-31T17:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956318#M428751</link>
      <description>&lt;P&gt;Although reading the whole thing and dealing with as one big chunk of data is easier to code, the user simply can't see it all at once. I just finished up an enahncement to an app to allow the end user to "replay" the app do fast forward etc. THe challenge I was facing that the amount of data that was collected (even in raw form) was more than could fit into memory. I worked arounf that issue by only displaying the current state and left the rest of the data on disk. It ran with much less CPU and memory demands than I was anticipating.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Aside:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A "reverse" button was also implemented. I never saw a chart "un-plot" data before this project. down-right disturbing if you ask me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to stay with the monolithic approach then an AE may be able to help you. Create an action that reads the data and do your file read in that case (not a sub-VI!) and cache the binary data in a Shift Register. In another action, select the record on interest, forat for display and return same to the caller.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If coded right, you&amp;nbsp; data will sit one buffer (the SR) and only the data associated with "now" is required for the update.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just trying to help,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2009 17:28:56 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956318#M428751</guid>
      <dc:creator>Ben</dc:creator>
      <dc:date>2009-07-31T17:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956322#M428753</link>
      <description>&lt;P&gt;The reason I asked was that I have a similar application where I store spectrometer snapshots (arrays of 2048 singles) in a binary file at a rate of 1-10 per second, sometimes over the course of several hours.&amp;nbsp; When I want to review the data, I have&amp;nbsp;an XY graph that displays one snapshot at a time.&amp;nbsp; Underneath the graph, I have a slider that I use to index the file and pull up the desired snapshot.&amp;nbsp; I can quickly run the slider back and forth and watch how my spectrum evolves over time.&amp;nbsp; It runs smooth and uses next to no memory... I was thinking something similar might have worked for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2009 17:32:21 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956322#M428753</guid>
      <dc:creator>Jason_P</dc:creator>
      <dc:date>2009-07-31T17:32:21Z</dc:date>
    </item>
    <item>
      <title>Re: Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956331#M428757</link>
      <description>&lt;P&gt;Ben-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AE?&amp;nbsp; Application Engineer?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the suggestions.&amp;nbsp; I have tossed around ideas for smarter loading and viewing of the data but haven't had a chance to try them out yet.&amp;nbsp; I squashed a pretty big memory issue yesterday that makes what I am seeing here look like nothing so I'm not too worried right now. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-dennis. &lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2009 17:46:11 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956331#M428757</guid>
      <dc:creator>dwj314</dc:creator>
      <dc:date>2009-07-31T17:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956334#M428759</link>
      <description>&lt;P&gt;Hey Jason-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your app does sound similiar; my data rates are much higher but that also means I am saving and loading data that is faster than a person can really see/respond to.&amp;nbsp; We are still in teh process of determining what rate we really need and how much data we need to save so I can see how this file will only descrease over time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks-&lt;/P&gt;&lt;P&gt;-dennis. &lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2009 17:50:59 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956334#M428759</guid>
      <dc:creator>dwj314</dc:creator>
      <dc:date>2009-07-31T17:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956341#M428764</link>
      <description>&lt;P&gt;AE = &lt;A href="http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=240328#M240328" target="_self"&gt;Action Engine&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2009 17:55:36 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/956341#M428764</guid>
      <dc:creator>Ben</dc:creator>
      <dc:date>2009-07-31T17:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Freeing memory when loading large binary files into memory</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/966355#M433173</link>
      <description>&lt;P&gt;Jason,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a similar application where I would like to view a section of data from a large file however I am having some trouble with it.&amp;nbsp;&amp;nbsp; I was trying to use the set position vi to set a marker and then read in the data from that point but I can not get it to work in real time.&amp;nbsp; How do you sift through the file on the disk?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2009 20:08:23 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Freeing-memory-when-loading-large-binary-files-into-memory/m-p/966355#M433173</guid>
      <dc:creator>Humada33</dc:creator>
      <dc:date>2009-08-17T20:08:23Z</dc:date>
    </item>
  </channel>
</rss>

