08-30-2010 11:00 AM
Hello,
I'm using LabVIEW2009 under windows XP (4Go RAM).
When I create a large array using the "Initilaize an array" fucntion (for example a 2D 512x512 array of U16), I've an error message "Insufficient memory" while this table weighs only 520kb if I try to use it (for example, save it to a binary file). My final need if a 2D 512x512 array of double precision.
Is there a maximum size for array in LabVIEW? If yes, could we modify it?
Thank you in advance,
Eric
08-30-2010 11:22 AM
That's very strange, you are correct the array is not that big.
Is your code making a lot of copies of the array?
Can you initialize the array on a fresh start:
-Reboot your PC
-Start LabVIEW
-Create an empty VI
-Place the initalization inside this VI
Run code.
One thing to advice, make one of your constants a control, this will prevent LabVIEW from doubling the memory upon editing the array in memory.*
Ton
*When you initialize an error with only constants LabVIEW will make the array a Constant in memory, when you edit the array, LabVIEW needs to declare a copy. This is very usefull for read-only (lookup) array.
08-30-2010 11:50 AM - edited 08-30-2010 11:52 AM
@egda wrote:
I'm using LabVIEW2009 under windows XP (4Go RAM).
I assume this is 32bit windows XP. Correct?
A 512x512 DBL array is not very big and you should have no problems creating it. Can you show us some code?
One thing: Arrays need to be contiguous in memory, so if your memory is highly fragmented, you could get this error even if there is enough free RAM.
You might also want to read this document.
08-30-2010 11:56 AM
I've used arrays several hundred MB in size before without a problem, so a 512x512 array of U16, or even double, shouldn't be a problem.
If you're unable to allocate a 520 kB array, it is likely due to one of two problems:
1. There is less that 520 kB free within the process's virtual memory space (2 GB for 32-bit windows). In this case, you'll have to find what is using/leaking the memory and fix it.
2. This is more than 520 kB free within the process's virtual memory space, but there is no single 520 kB block free. In this case you'll either have to avoid fragmenting the virtual memory space (usually by avoiding creating and freeing lots of large data structures) or you'll have to change your program to use data structures which require smaller contiguous regions of memory (for example queues instead or arrays).
Also, check the obvious. For example make sure your allocating a 512x512 array initialized to 100,000, not a 100,000x512 array initialized to 512.
Mark Moss
Electrical Validation Engineer
GHSP
08-31-2010 08:46 AM
I did another test today on another PC : it works. I either made a mistake in my or my other PC had a memory problem.
Do I conclude from your explanation that there is no limit array size in LabVIEW, and the only existing limitation is related to the PC's RAM, and more precisely to the contiguous virtual memory space ?
In this case, on my PC under XP32bits with 4Go RAM (I use the tag /3GB in the boot.ini file) the attached code (500M samples of U8) should work ? (I have an error : memory full). Or do LabVIEW (or windows) use more memory than the minimum required ? (in my example, do I need 500Mb memory or do I use 2x500Mb because I use an indicator)?
08-31-2010 08:51 AM
As previous posters have indicated the amount of RAM in your machine is the first concern. Then there is the question of how much is actually available to your program, whether it is contiguous (all one block) or fragmented. Another issue is how you are using it in your program, for instance branches or connections into certain types of LabVIEW structures will create copies of the array, meaning more that double the requirement. 500M would be a big array, and unless you were very careful almost any manipulation of the array would cause copies.
08-31-2010 08:56 AM - edited 08-31-2010 09:00 AM
You are running out of memory due to memory fragmentation. You can use this library in order to try to circumvent the issue. But displaying such data is not possible, so you have to extract parts of data if you want to show something.
Regarding your original question:
512x512 = 262144 Elements. I have never seen LV failing to allocate memory even with extended data type (10 bytes)........
So i have no idea what went wrong there. But as i read your first two sentences, it seems that this issue is solved.
hope this helps,
Norbert
EDIT: Yes, the indicator will copy the data, so you will need two different arrays with the size of 500MB each
08-31-2010 09:40 AM
Thank you for these very clear explanations. The VI "Contiguous_mem_example.vi" help realize this notion of contiguous block. I will try using the provide library.