Is there a way to perform a leak detection test like the debug crt in VC?. For example, when I'm about to release the scripting engine, I *should* not have any references to objects, so it should be straightforward to ask the garbage collector or the scripting engine if it still holds references to objects, but how to do that?
Something like:
asIScriptEngine* engine = ...;
// run some scripts, and acquire object references
// Finish...
if (engine->GetTotalRefCount() > 0)
{
// Leaks!
}
engine->Release();
Thanks!
Leak detection
I don't think it'd be a straightforward as that. Modules can have global variables which can hold references so even if you're done with everything that doesn't mean that there won't be references live in the engine.
As AngelScript uses automatic memory management, there shouldn't be any leaks. If there are, then it would be a bug in the library that I need to fix, or the improper registration of application classes which needs to be fixed by the application developer.
In either case, it isn't something that could be detected by the library. It wouldn't be a leak if the library knew about it. ;)
You can get the number of objects known to the GC with a call to asIScriptEngine::GetGCStatistics. Only objects that have a chance of forming circular references will be known to the GC, so that it can detect and resolve these if necessary. Remember that the Garbage Collector is not automatically invoked (except when releasing the engine), so the application needs to do that (preferably incrementally to avoid potentially blocking the application for long periods).
In either case, it isn't something that could be detected by the library. It wouldn't be a leak if the library knew about it. ;)
You can get the number of objects known to the GC with a call to asIScriptEngine::GetGCStatistics. Only objects that have a chance of forming circular references will be known to the GC, so that it can detect and resolve these if necessary. Remember that the Garbage Collector is not automatically invoked (except when releasing the engine), so the application needs to do that (preferably incrementally to avoid potentially blocking the application for long periods).
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement