The problem with re-dimensional arrays in
VB is that when you first use them a block of memory will be allocated for it, then when you re-dimension the array the system will try to increase the size of the block of memory and will not use a new block of memory if you want to preserve the data already in the array. If the block of memory can not be increased to the size you require because there is another block of memory
in the way, then you will get an out of memory error. Even though there is enough free physical memory, the block of memory being used can not be increased to the size you require.
First of all, are you re-dimensioning the array a lot? If at all possible re-dimension the array as infrequently as you can. What I will often try to do if I am increasing the size of an array in a loop for example, is to increase it by more than I need, then as the loop continues I will use the spare elements of the array instead of re-dimming the array again and again. Then if and when I reach the end of the array and still want to add more data I will re-dim it again by more than I need.
Secondly, can you use a static array? A static array will be much friendlier to your application, improving both performance and memory usage. This is because when your application starts the system will know how much memory is required for the array and it will know that it will never need to change this memory allocation.
Regards
Owain Williams