pcoder 5 Posted Saturday at 01:14 PM procedure TObj.run; var r: TRecord; begin ...; processRecord( r); ...; end; ProcessRecord is a method and contains many nested calls (more methods). The issue is that many methods would need an additional parameter (very cumbersome). Therefore an alternative is wanted. Object-field FR (PRecord) is a pointer (rather than record) to reduce memory outside of runs. is there any preference for one of them? procedure TObj.run2; begin new( FR); ...; processRecord; ...; dispose(FR); FR := nil; end; procedure TObj.run3; var r: TRecord; begin FR := @r; ...; processRecord; ...; FR := nil; end; Â Share this post Link to post
Remy Lebeau 1641 Posted Saturday at 05:01 PM (edited) I would choose the latter. No need to allocate memory dynamically unless the record instance needs to live after TObj.run3() exits.  But, if you have a lot of methods of TObj that are acting on the record then they should instead be methods of TRecord itself. Consider refactoring your code to make it cleaner. Edited Saturday at 05:02 PM by Remy Lebeau 1 Share this post Link to post