Issue #31 new

Add PetscRealloc

Jed Brown
created an issue

The realloc function allows the operating system to optionally reuse existing memory. Adding support in PETSc, but it expands the allocation API and logging will need to be taught to detect and expand such memory locations.

Comments (2)

  1. BarryFSmith

    I've always resisted adding this to the PETSc API.

    Is there any quantative indication that having this API bloat brings anything besides API bloat?

  2. Jed Brown reporter

    It is less code and less expensive when buffers need to be expanded in dynamic data structures. PETSc usually uses special "freespace" components to guarantee that reallocation does not occur, but sometimes you want the result to be contiguous.

    But more importantly than performance, the leading motivation is convenience. As it is, a lot of users will call system realloc out of convenience, thus giving up the profiling capability and leak checking of PetscMalloc.

  3. Log in to comment