Delphi Memory Management

Posted by nomad311 on Stack Overflow See other posts from Stack Overflow or by nomad311
Published on 2010-03-24T19:08:51Z Indexed on 2010/03/24 19:33 UTC
Read the original article Hit count: 138

Filed under:
|
|

I haven't been able to find the answers to a couple of my Delphi memory management questions. I could test different scenarios (which I did to find out what breaks the FreeAndNil method), but its takes too long and its hard! But seriously, I would also like to know how you all (Delphi developers) handle these memory management issues.

My Questions (Feel free to pose your own I'm sure the answers to them will help me too):

  1. Does FreeAndNil work for COM objects? My thoughts are I don't need it, but if all I need to do is set it to nil than why not stay consistent in my finally block and use FreeAndNil for everything?

  2. Whats the proper way to clean up static arrays (myArr : Array[0..5] of TObject). I can't FreeAndNil it, so is it good enough to just set it to nil (do I need to do that after I've FreeAnNil'd each object?)?

Thanks Guys!

© Stack Overflow or respective owner

Related posts about delphi

Related posts about memory-management