Re: Array of byte of unknown size

From: Mike Manning (NOMORESPAM_at_nowhere.com.au)
Date: 11/17/03


Date: Tue, 18 Nov 2003 08:04:39 +1100

Hi Peter
The example given in the control's help file is for Visual Basic - so
they've used the VB dynamic array:
ie ..
Dim data() As Byte
data = Control1.SaveToMemory

I may have missed something (and wasted a lot of my time) but after hunting
through the Delphi help file and Google I couldn't see any way of doing the
same thing with a variant array in Delphi

Mike

"Peter Below (TeamB)" <100113.1101@compuXXserve.com> wrote in message
news:VA.0000a6be.005823e3@nomail.please...
> In article <3fb8c96e$1@newsgroups.borland.com>, Mike Manning wrote:
> > In my Delphi 5 app I'm using a variant array to receive binary data from
a
> > third party activeX control, for subsequent storing in a database.
> >
> > Unfortunately its not possible to know in advance the size of the data
in
> > the control - it could be 100 byte or 10 Mbyte or more.
> >
> > What I'm wondering is - if I set the bounds of the array to a high
number -
> > eg 100 MByte -
> > buf := VarArrayCreate([0, 100000000], varbyte)
> > so that I can be reasonably sure it will always be larger than the sixe
of
> > the control's data, what implications does that have for memory
resources ?
>
> Dire ones. I see out of memory errors in your future.
>
> > ie does VarArrayCreate try to allocate that amount of memory ?
>
> Of course.
>
> >
> > (Unfortunately I can't get the control's data in "chunks" - it has to
come
> > all at once by calling the control's "save to memory" method.)
>
> ActiveX controls that return data in variant arrays usually work this way:
> you pass them an *empty* variant by reference and they allocate the
required
> memory for its content, which you then use and free (automatically when
the
> variant goes out of scope).
>
> --
> Peter Below (TeamB)
> Use the newsgroup archives :
> http://www.mers.com/searchsite.html
> http://www.tamaracka.com/search.htm
> http://groups.google.com
> http://www.prolix.be
>
>



Relevant Pages

  • Re: Reclaiming Memory
    ... example, handles to device context, memory addresses, etc.), VB is actually ... VB will clean up references to objects all ... It's a little unusual to use an array to store object references. ... unusual to use a variant array for what you apparently are (at least I'VE ...
    (microsoft.public.vb.com)
  • Re: Fast string operations
    ... Looping: I thought looping over arrays in managed code was "slow" ... array handling and such. ... The problem with TrimHelper is that it always returns a new string instance. ... The customer perceives this as a memory leak. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: High Memory Consumption of Classes and Arrays
    ... Only the array itself has overhead. ... memory as a reference type. ... > least consume 40 bytes of memory. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: Fast linked list
    ... > amounts of memory rather than huge chunks of it. ... random insertions into a vector/dynamic array are not as slow ... to cause a cache miss. ... some hard numbers on speed differences between lists and arrays. ...
    (microsoft.public.vc.mfc)
  • Re: Fast linked list
    ... > amounts of memory rather than huge chunks of it. ... random insertions into a vector/dynamic array are not as slow ... to cause a cache miss. ... some hard numbers on speed differences between lists and arrays. ...
    (microsoft.public.vc.language)