Board index » delphi » Out of memory while expanding memory stream

Out of memory while expanding memory stream

Got this error "Out of memory while expanding memory stream" while using
TMemoryStream.
Checked current TMemoryStream.Size is less than 8 MB (physical memory
256 MB).
Any solution?

Thanks in advance.
    Rimvydas

 

Re:Out of memory while expanding memory stream


Quote
In article <3EEEEFC6.E5FE6...@post.5ci.lt>, Rimvydas Paulavicius wrote:
> Got this error "Out of memory while expanding memory stream" while using
> TMemoryStream.
> Checked current TMemoryStream.Size is less than 8 MB (physical memory
> 256 MB).
> Any solution?

THis may be a problem of memory fragmentation. Set the TMemoryStreams
Capacity to a large value before you start to write to it. Capacity is a
protected property, so you need a cracker class:

 type
   TMemStreamCracker = class( TMemoryStream )
   public
     property Capacity;
   end;

Cast your instance to this type to access Capacity.

--
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

Other Threads