Your probably right. That makes sense.
It's certainly easier to code than using static blocks and reusing them. From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of Rohit Gupta Sent: Friday, 24 September 2010 12:48 PM To: NZ Borland Developers Group - Delphi List Subject: Re: [DUG] Memory allocation speed I think that because your chunk size is constant, the memory manager just returns previous blocks to you. So fragmentation does not occur. On 24/09/2010 01:52, Ross Levis wrote: Just wanted some opinions on how bad a practice this is! I have written a media player which uses a DLL to decode audio files. The DLL opens an MP3 file for example, and sends back decoded raw audio, usually in chunks of 4608 bytes (~20ms), but could be a different size. I need to buffer this audio data for around 5 seconds (1 MB). Rather than writing a complicated circular buffer which feeds in one end and is taken from the other, I decided to simply allocate memory for each new chunk and store a link from one memory location to the next. The oldest buffer is read and memory released. So there is roughly 1 new memory space being allocated and 1 being destroyed every 20ms or so, with around 200 chunks being stored at any one time. I'm using D7 with the FastMM4 memory manager. It is working very well with very little CPU usage at all, which I was surprised at. I've always been under the impression that allocating memory is a slow process. Thoughts? __________ Information from ESET NOD32 Antivirus, version of virus signature database 5472 (20100923) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe __________ Information from ESET NOD32 Antivirus, version of virus signature database 5472 (20100923) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com -- Regards Rohit Gupta B.E. Elec., M.E., Mem IEEE, Member IET Technical Manager Computer Fanatics Ltd Tel 4892280 Fax 4892290 Web www.cfl.co.nz _____ This email and any attachments contain information, which is confidential and may be subject to legal privilege and copyright. If you are not the intended recipient, you must not use, distribute or copy this email or attachments. If you have received this in error, please notify us immediately by return email and then delete this email and any attachments.
_______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe