mlua icon indicating copy to clipboard operation
mlua copied to clipboard

Add `Lua::(reset_)num_allocations` API

Open cr0sh opened this issue 2 years ago • 1 comments

I was in need to track the number of memory allocations, so added an API to support this.

  • Lua::num_allocations simply returns a number of allocations invoked by Lua runtime since the runtime has been created.
  • Lua::reset_num_allocations resets the counter.

cr0sh avatar Sep 16 '23 07:09 cr0sh

Thanks for the PR!

Seems the current version has breaking changes (renaming MemoryLimitNotAvailable to MemoryStatsNotAvailable) which makes it hard to include into v0.9 branch. Wondering, would be better to keep the original error code and add a new one (Error enum is non_exhaustive so it's not breaking change). I'm happy to merge error codes into a single one in the next major release.

khvzak avatar Oct 02 '23 09:10 khvzak