Skip to content

AMReX Initialize/Finalize as Context Manager #81

Open
@ax3l

Description

@ax3l

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

import amrex

amrex.initialize([])
mfab = amrex.MultiFab( ... )
del mfab  # freed in CPython, but not guaranteed by Python per se
amrex.finalize()

This code can lead to Python holding on to mfab over the lifetime of amrex.finalize(). When using memory in an AMReX area, their actual free after finalize() will be UB and usually segfault.

Refs.:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions