03-17-2016 10:57 AM
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
03-17-2016 11:24 AM
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.
03-17-2016 12:29 PM
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.
03-17-2016 12:38 PM
@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.
03-17-2016 12:55 PM
@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.
03-18-2016 03:59 AM
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.
03-18-2016 04:19 AM - edited 03-18-2016 04:20 AM
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.