Advertisement

How to let each engine instance use their own memory pool instance?

Started by June 11, 2021 04:20 AM
1 comment, last by WitchLord 3 years, 6 months ago

Firstly please let me describe the scenario I'm facing:

  • I'm trying to use AngelScript in real-time audio processing. There must no locks, and I should not use one global memory pool for many script instances. In addition, the memory pool I'm using does not support multithread access at all.
  • Suddenly I attempted to use thread-local instances of memory pool, but it is not valid: some host DAWs maintains a thread pool for audio processing, and the specific thread you use may vary. So if I use a thread-local memory pool, it is possible that AngelScript get allocating in one memory pool but releasing in another, which is fatal.

It seems my only choice is let each script engine instance to use a specific private pool. However, the custom memory allocation mechanism asSetGlobalMemoryFunctions is a pair of global function, and it does not know which engine instance it is working with. So is there any way to have each engine to use their own pool?

There is currently no support for per-engine custom memory management.

You might be able to do it by modifying the library, so that when a memory block is allocated by an engine the memory pool id is stored next to the memory block. That way when freeing the memory block you could identify to which memory pool the memory block should be returned.

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