Re: [fpc-devel] Growing a memory stream

2006-12-13 Thread Michael Van Canneyt
On Tue, 12 Dec 2006, [EMAIL PROTECTED] wrote: > Attached patch grows a memory stream by at least a quarter of its original > capacity. Thank you, applied. Michael. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org

[fpc-devel] Growing a memory stream

2006-12-12 Thread vsnijders
Attached patch grows a memory stream by at least a quarter of its original capacity. Vincent Index: streams.inc === --- streams.inc (revision 5577) +++ streams.inc (working copy) @@ -535,11 +535,17 @@ function TMemoryStream.Realloc(

Re: [fpc-devel] Growing a memory stream

2006-12-11 Thread Vincent Snijders
peter green schreef: Well, the linked list would be freed (or the first item of it enlarged to the total size, depending on implementation details). Still, the peak memory use will twice the size, won't it? sure but unless you are very lucky a call to reallocmem also means alocate-copy-deallocat

RE: [fpc-devel] Growing a memory stream

2006-12-11 Thread peter green
> > Well, the linked list would be freed (or the first item of it enlarged > > to the total size, depending on implementation details). > > Still, the peak memory use will twice the size, won't it? sure but unless you are very lucky a call to reallocmem also means alocate-copy-deallocate.

Re: [fpc-devel] Growing a memory stream

2006-12-11 Thread Vincent Snijders
Micha Nelissen schreef: Vincent Snijders wrote: A (maybe shortsighted) drawback would be that it doubles the amount of needed memory, once for the list and once for the memory pointed to with Memory? Well, the linked list would be freed (or the first item of it enlarged to the total size, depe

Re: [fpc-devel] Growing a memory stream

2006-12-11 Thread Micha Nelissen
Vincent Snijders wrote: > A (maybe shortsighted) drawback would be that it doubles the amount of > needed memory, once for the list and once for the memory pointed to with > Memory? Well, the linked list would be freed (or the first item of it enlarged to the total size, depending on implementatio

Re: [fpc-devel] Growing a memory stream

2006-12-11 Thread Vincent Snijders
Micha Nelissen schreef: Vincent Snijders wrote: Hi, Currently the TMemoryStream grows in steps of 4096 bytes. Very nice would be a linked list of 8KB blocks or so, and when you access .Memory, then it's copied into an array. A (maybe shortsighted) drawback would be that it doubles the am

Re: [fpc-devel] Growing a memory stream

2006-12-11 Thread Michael Van Canneyt
On Mon, 11 Dec 2006, Micha Nelissen wrote: > Vincent Snijders wrote: > > Hi, > > > > Currently the TMemoryStream grows in steps of 4096 bytes. > > Very nice would be a linked list of 8KB blocks or so, and when you access > .Memory, then it's copied into an array. I think you can create a sepa

Re: [fpc-devel] Growing a memory stream

2006-12-11 Thread Micha Nelissen
Vincent Snijders wrote: Hi, Currently the TMemoryStream grows in steps of 4096 bytes. Very nice would be a linked list of 8KB blocks or so, and when you access .Memory, then it's copied into an array. Micha ___ fpc-devel maillist - fpc-devel@lis

Re: [fpc-devel] Growing a memory stream

2006-12-11 Thread Michael Van Canneyt
On Mon, 11 Dec 2006, Vincent Snijders wrote: > Hi, > > Currently the TMemoryStream grows in steps of 4096 bytes. > > When writing 10 chunks of say 80 bytes to it, this causes a lot of > reallocations. I think it is better to grow at least a quarter for example. > > The new code could look

[fpc-devel] Growing a memory stream

2006-12-11 Thread Vincent Snijders
Hi, Currently the TMemoryStream grows in steps of 4096 bytes. When writing 10 chunks of say 80 bytes to it, this causes a lot of reallocations. I think it is better to grow at least a quarter for example. The new code could look something like: function TMemoryStream.Realloc(var NewCapaci