Advertisement

Profiling allocations caused by scripts

Started by December 23, 2024 10:02 PM
1 comment, last by WitchLord 1 day, 1 hour ago

I'm trying to make a profiler for scripts to pinpoint hotspots in the code that allocate a lot of memory. To do so i need to have a callback execute whenever an object is created. I tried to use the context's line callback but it doesn't execute during the creation of an object.

I think what's needed is a callback executed in asCScriptEngine::CreateScriptObject. Right before it returns the allocated object there should be an optional invocation of a callback that passes the type and object:

void AllocCallback(asITypeInfo* type, void* obj);

So there should be a set and clear function for this callback just like there is for the line callback but on the engine.

I don't think this can be used to track allocations in containers but that can be done by the application developer.

Contextual information like which script and function the allocation is performed by can be retrieved using existing functions so that should be fine.

With this callback in place it should be possible to show script authors where their script is allocating a lot of memory and causing slowdowns.

Some way to see which function is about to be executed by a script would also be useful for profiling, to see which function calls (especially system function calls which don't get line callbacks) are taking a long time. I don't see any way to get this information from the context right now.

I'm away on vacation right now. I'll look into this better when I come back home in the second week of January.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement