Re: Read very large file in bytearray and upload to MSSQL

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



That's an idea offcourse, but not very optimal.

On 19 nov, 13:54, Family Tree Mike
<FamilyTreeM...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Can't you just find the maximum size file, allocate the array to that size,
and reuse the array in a loop over all files?



"Armin Zingler" wrote:
"Icemokka" <icemo...@xxxxxxxxx> schrieb
Your proposal ( option strict & Cint(lenght - 1 ) fixed my problem.
Now I have a second problem, there are 4 * 600Mb files ready to be
put in the database.
After the first file, I see that my app takes 600Mb of memory (
logic offcourse ).
But I get an out of memory exception on the second file because the
bytearray has not yet released it's memory ( set it to nothing
within the function ).

That's a good question. I'm afraid, I can't answer this. I would have
thought that GC will do it automatically. Do I understand it correctly that
you did set the reference to the array to Nothing /before/ creating the new
array?

I mean,

this
var = nothing
redim var(...)

is not the same as

redim var(...)

because in the 2nd case, first the new array is created before the last
reference to the old array has been cleared. So, the 1st version should be
preferred. Though, I don't know if it helps and if the next Redim will wait
until the GC will have destroyed the previous array.

How can I force that the garbage collector cleans up ( array's don't
have dispose or finally method ).

There's the GC.Collect method, but usually it shouldn't be called manually.
Maybe this is an exception. Let's wait for other answers.

Armin- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

.



Relevant Pages

  • Re: Framework 2.0 array redim unsatisfactory performance
    ... I am not talking about "array redim" anymore. ... ReDim simply allocates a new ... but I do not even attempt to test its memory ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Arrays
    ... As long a pointers are properly and timely restored/maintined, no memory ... leaks occur. ... dimensional array is just a continuous block of memory. ... ReDim columns ...
    (microsoft.public.vb.general.discussion)
  • Re: Arrays
    ... If you are careful, and the data are simple value types like double or long, then you can use copy memory to move the blocks around as a mutli dimensional array is just a continuous block of memory. ... Dim columns() As Variant ... ReDim columns ...
    (microsoft.public.vb.general.discussion)
  • RE: Arrays/Redim/Help!
    ... The rule with multi dim arrays is that you can only redim the last element in ... ReDim ary ... It has to do with the way memory is stored. ... A multi dim array, like any ...
    (microsoft.public.excel.programming)
  • Re: Fexible Arrays
    ... How do you make a flexible array. ... redim preserve arMyArray ... releases memory used before (it may reuse the same memory, ...
    (microsoft.public.vb.general.discussion)