blitz icon indicating copy to clipboard operation
blitz copied to clipboard

Improve array memory releasing mechanism

Open bpalak opened this issue 3 years ago • 1 comments

An array can have various memory management policy: duplicate, neverDelete, deleteWhenDone... Calling array.free(), doesn't release memory of array having neverDelete policy. Unfortunately there is no way to check what policy was used at array creation time, so it cannot be determined if array data should be released manually or not. Moreover, array.free() nullifies a pointer to data even if memory was not automatically deallocated. Potential solutions: A) (the simples one) to not nullify _data private variable if memory was not automatically deallocated. After calling array.free(), user may check if pointer is valid - if so, memory can be freed manually. B) to expose memory policy via array method to provide user knowledge if an array must be deallocated manually

bpalak avatar Nov 19 '21 07:11 bpalak

Thank you for reporting it! IIUC, option B has the advantage of not changing the existing behaviour. Would it be possible for you to create a PR for it? Thanks, Sylwester

slayoo avatar Dec 04 '21 06:12 slayoo