Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve array memory releasing mechanism #174

Open
bpalak opened this issue Nov 19, 2021 · 1 comment
Open

Improve array memory releasing mechanism #174

bpalak opened this issue Nov 19, 2021 · 1 comment

Comments

@bpalak
Copy link

bpalak commented Nov 19, 2021

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

@slayoo
Copy link
Member

slayoo commented Dec 4, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants