LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read from binary file labview

Hello,

I have to read a binary file bigger than 128Mb. Read from binary file function returns memory error. How can I solve the problem? Thanks

0 Kudos
Message 1 of 7
(4,038 Views)

You should figure out where exactly the memory overflow has it's origin.

I just think it's too error prone to read such a big file at once. You can read it in more mouthfriedly morsels and then

assemble the parts in some data structure in memory. Then you can retrieve error info after each bunch is read and determine on which

bunch it occurs at first. 

Is the file read directly after the vi starts or may memory be alreadly allocated by other variables/sub vis already called?

In the second case the problem may have it's origin at another place in the program flow.

   

0 Kudos
Message 2 of 7
(4,024 Views)

What, exactly, are you trying to read?  If this is just raw data, use the Read from Text File Function and disable the Convert EOL property.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 7
(4,010 Views)

@NicRinED wrote:

I have to read a binary file bigger than 128Mb. Read from binary file function returns memory error. How can I solve the problem?


What else are you doing with the data?  Can you share your code?

 

The most likely solution here is to read the data in chunks, like 1MB at a time or something like that.


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 4 of 7
(4,001 Views)

@crossrulz wrote:

@NicRinED wrote:

I have to read a binary file bigger than 128Mb. Read from binary file function returns memory error. How can I solve the problem?


What else are you doing with the data?  Can you share your code?

 

The most likely solution here is to read the data in chunks, like 1MB at a time or something like that.


I see what you guys are getting at.  I failed to see the "128 MB" part.  What the data represents is going to determine how to break it up into chunks, to a certain extent.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 7
(3,992 Views)

Yes, but it's obvious that the binary read is not the only cause of the memory overflow.

Reading 128MB at once is generally not a good practice in my opinion although Labview is able to handle

this principally. If LV could not handle 128MB files principally i would say yes, the binary read is the source of the problem.

But this ain't the case and therefore it follows that the reason for the memory overflow is not the binary read.

There must be other data structures in memory which consume more space and the 128 MB is just the upper rest which

leads to the overflow.

 

0 Kudos
Message 6 of 7
(3,948 Views)

That depends a lot what the code does with the 128MB binary data. LabVIEW is a dataflow language and if you are not careful you can easily create numerous copies of that 128MB block. Every subVI with open front panel and a control on it where this 128MB block is flowing through will have a local data copy of that block in the control data space. Also wire branching will easily create extra copies too. An unitialized shift register will retain a copy too.

 

So depending on the clean programming or lack thereof of the diagram when dealing with that 128MB block it's very easy to use up many times the 128MB memory just for this single binary read. Generally even when programming very clean and optimal it will be almost impossible to not use up at least double the amount and with sloppy programming you can end up with 10 times and more that amount very easily.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 7
(3,939 Views)