Jump to content
Sign in to follow this  
RDP1974

TDICTIONARY

Recommended Posts

I was wondering about use a record instead of a class or a object

if add will call a mem place for the record

of maybe if we should use New and Dispose on remove

probably is better stay with a basic class creation and disposal

 

the doc is unclear, if remove dispose the loaded struct or should be done manually

Share this post


Link to post
3 hours ago, RDP1974 said:

hi,

do you know if https://docwiki.embarcadero.com/Libraries/Sydney/en/System.Generics.Collections.TDictionary.Remove

remove method will dispose an inserted record automatically?

Records are value types, so adding a record to a TDictionary<recordtype> adds a copy of the record to the internal storage, and Remove then clears up that copies memory. So there are no leaks, but adding a record and getting it back later always makes a full copy of the record, which can be a bit hard on performance.

  • Like 2

Share this post


Link to post

Are you holding records or pointers to records? Because the question only makes sense if the latter. If the latter then something needs to allocate and deallocate. But i suspect that you are doing the former. 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×