Skip to content

How To Investigate Memory Leaks

Matt Norman edited this page May 31, 2022 · 3 revisions

Memory leaks in most YAKL codes are uncommon and typically indicative of a potential bug in the device pool allocator or perhaps the thread safety if run in a threaded region. The best way to investigate a potential memory leak on the device, however, is to use Gator's printing feature at the end of every "iteration" (however you define that in your model, e.g., time step):

while (etime < sim_time) {
  // perform_time step
  etime += dt;
  yakl::pool.printAllocsLeft();
}

Then pay attention to any repeat entries in the printed list that increase with iteration count. You'll need to compile with the -DYAKL_DEBUG compiler flag so that allocation labels are more likely to be propagated to the pool allocator.

Important: If you find a situation where the same entry is repeated more and more often with each time step / iteration, please let me know with a GitHub Issue on this repo so I can look into it. Reproducers are encouraged.

Clone this wiki locally