Our memory allocation "strategy" is pretty inconsistent at the moment. In many places, we use PetscMalloc and PetscFree, while in others we use malloc and free. In still other places, we have utility functions for allocating "multi-dimensional arrays", which appear to be "ragged arrays" instead of contiguous blocks (which is not good). It's kind of a mess, and we recently chased down a few cases where mallocs were being freed with PetscFree, for example.
At some point, we need to decide on a simple memory allocation strategy (probably involving PetscMalloc and PetscFree) that prevents developers or users from just "doing whatever." This isn't hard, but it will take a little effort to reorganize things and eliminate all the inconsistencies related to memory allocation in the code.
Our memory allocation "strategy" is pretty inconsistent at the moment. In many places, we use
PetscMalloc
andPetscFree
, while in others we usemalloc
andfree
. In still other places, we have utility functions for allocating "multi-dimensional arrays", which appear to be "ragged arrays" instead of contiguous blocks (which is not good). It's kind of a mess, and we recently chased down a few cases wheremalloc
s were being freed withPetscFree
, for example.At some point, we need to decide on a simple memory allocation strategy (probably involving
PetscMalloc
andPetscFree
) that prevents developers or users from just "doing whatever." This isn't hard, but it will take a little effort to reorganize things and eliminate all the inconsistencies related to memory allocation in the code.