TDycores-Project / TDycore

BSD 2-Clause "Simplified" License
4 stars 0 forks source link

Simplify and improve memory allocation #229

Closed jeff-cohere closed 2 years ago

jeff-cohere commented 2 years ago

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.