Tracking memory usage by function

  • From: Qingjun Wei <wei.qingjun@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sat, 1 Aug 2015 20:21:48 -0400

I would like to be able to track memory usage on function basis.

I am not very familiar with the LuaJIT design. By just browsing through the
code I am wondering if it is possible to try the following?

1. Assign an integer ID to each function
2. Add another field into GCobj struct for function ID
3. During (re)allocation process increment the function memory usage by
specific amount.
4. During GC process decrement the memory from the function identified by
function ID field.

If it is feasible can anybody point me some where should I add the hooks?

BTW, in my application I can assume that each function is fairly
independent in term of object management. I understand my requirement is
not for everybody.

Thanks in advance

Other related posts: