-
Notifications
You must be signed in to change notification settings - Fork 19
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
AMReX Initialize/Finalize as Context Manager #81
Comments
The Arenas in amrex is fine in this. That's why BArena never dies. |
Yes, but tests that run on pure device MultiFabs should be tearing down cleanly as well before import amrex
amrex.initialize([])
mfab = amrex.MultiFab(
boxarr,
distmap,
num_components,
num_ghost,
amrex.MFInfo().set_arena(amrex.The_Device_Arena()),
)
del mfab # freed in CPython, but not guaranteed by Python per se
amrex.finalize() |
The device arena is also fine.
|
|
Hm, I get a double free after finalize on process shutdown when I keep such an |
Also, I kinda want to be sure that I have a context where all Arena (CPU/GPU) memory is free'd again. In testing, we need to run 100s of small init/finalize tests in the same process quickly after reach other - they should not leak memory after each of of these tests. |
Oh I see what you mean, finalize will free all memory we allocated in arenas? @WeiqunZhang |
Correct. But maybe things are different when python is involved. |
That sounds good. I'll try to build a reproducer for the issue I see and change to not use a fixture that is cached in pytest, when I need a multifab. Another bandage I'll apply for the pattern above is to call |
#214 binds |
@ax3l is there a reason why |
@sayerhs yes, the idea is to clean it out for every test and start fresh, so they are isolated. Example: different parameters in |
We cannot rely on the last
del
/reference drop to an object to really release and free the object in Python:https://stackoverflow.com/a/17644536/2719194
This code can lead to Python holding on to
mfab
over the lifetime ofamrex.finalize()
. When using memory in an AMReX area, their actualfree
afterfinalize()
will be UB and usually segfault.Refs.:
The text was updated successfully, but these errors were encountered: