Advertisement

Memory leak in AS due to thread-local data

Started by February 17, 2025 12:12 PM
2 comments, last by Jan K 2 days, 21 hours ago

I run AS in a multi-threaded environment, using a custom allocator which (in debug) tracks allocations to detect memory leaks.

Unfortunately, in this scenario AS allocates data in a thread local variable, and doesn't free that data anymore. This happens in asCThreadManager::GetLocalData().

I call ShutDownAndRelease, which does call asCThreadManager::CleanupLocalData(), but that only frees the memory of the active thread.

I see no way to free the memory of the remaining threads.

Any ideas? Anybody else solved this before?

The second bullet in the article “Things to think about with a multithreaded environment” says:

  • Always call asThreadCleanup before terminating a thread that accesses the script engine. If this is not done, the memory allocated specifically for that thread will be lost until the script engine is freed.

Are you calling this function and still getting the leaks? Or is it perhaps so that you cannot for some reason call this function and need to find another way to do the clean up?

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

Weird, I had searched through Google quite a while for this topic, but don't think that this page came up.

Anyway, with that information I got it working, thanks!

Advertisement