Thank you very much Cosmin. It really seems a good solution but it is indeed not very easy to implement as I not so good a pointers and API calls. I'm back to FastMM which didn't crash my application is I remove the EnableMemoryLeakReporting flag. FastMM didnt help me only with that huge string but it also increased application's speed. Now the problem moved in other place :) IE6 will die trying to load a 10MB HTML file, Netscape 7.2 will load the file but in 1-2 minutes :( But this is another story.
Anyway your idea worth to be stored in a safe place until need it. --- Cosmin Prund <[EMAIL PROTECTED]> wrote: > If you really want to go the fastest possible way, you can do something like > this: > > 1) Allocate an huge Virtual Memory buffer (100 Mb would be fine) but without > reserving any pages! > 2) Reserve one page of memory at the beginning of that huge buffer. > 3) Build your string into that buffer. You'd initially set the first byte to > zero and you'd set a index var to 0 (the first byte in your huge buffer). > You'll figure it out your self. > 4) When your next copy into the string would go beyond the amount of > reserved memory - reserve some more memory! > > Pros: > - No memory reallocations are required. > - No memory fragmentation will occur. You'll be eating up a 100Mb address > space chunk but beyond that you will not be touching the address space > again. > - You will not cause any issues with other programs as each Win32 program > gets it's own 2Gb address space. Using 100Mb of that address space will > probably not create any problems for you either. > - Your program will optimally use memory. You'll never be more then one page > ahead with your reserved memory allocation (and that's what counts). > > Cons: > - Working with virtual memory is not easy. > - You'd be doing a lot of pointer arithmetic. That's the only thing more > difficult then working with pure pointers :-) > > If you're up to it and fairly good with pointers you can put it all together > in less then 10 min. > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:delphi-talk- > > [EMAIL PROTECTED] On Behalf Of Human > > Sent: Saturday, March 04, 2006 1:49 PM > > To: Delphi-Talk Discussion List > > Subject: Re: Re[2]: Strings in Delphi should be 2GB, right? > > > > Thank you. > > I already switched to your solution since FastMM is unreliable. > > It looked so good/fast but the totally lack of documentation and AV it > > generate since I've > > installed it are time consuming. > > > > I'm a little bit disappointed. I never imagine it will be so complicated > > to write a 1-10MB string. > > > > > > > > > > --- Wilfried Mestdagh <[EMAIL PROTECTED]> wrote: > > > > > Hello Human, > > > > > > > Also, I discovered that I need to keep the whole report in memory > > > > until it is fully built, then I have to sort the paragraphs in a > > > > special order. So, writing to disk is excluded. > > > > > > Then you have to do a lot of Move's after the whole buffer is build. To > > > avoid that you can allocate a buffer per paragraph and add it to a > > > TList. Make each buffer the maximum predicted size of the paragraph. > > > > > > For the sorting you just have to move pointers in the list. Very quick. > > > > > > --- > > > Rgds, Wilfried > > > http://www.mestdagh.biz > > > > > > __________________________________________________ > > > Delphi-Talk mailing list -> [email protected] > > > http://www.elists.org/mailman/listinfo/delphi-talk > > > > > > > > > ...and the traveler died, stroked by the beauty of the landscape. > > > > THE MORNING OF THE MAGICIANS > > Louis Pawels & Jacques Bergier > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam protection around > > http://mail.yahoo.com > > __________________________________________________ > > Delphi-Talk mailing list -> [email protected] > > http://www.elists.org/mailman/listinfo/delphi-talk > > __________________________________________________ > Delphi-Talk mailing list -> [email protected] > http://www.elists.org/mailman/listinfo/delphi-talk > ...and the traveler died, stroked by the beauty of the landscape. THE MORNING OF THE MAGICIANS Louis Pawels & Jacques Bergier __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com __________________________________________________ Delphi-Talk mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi-talk
