I’m a bit of a newb when it comes to FMOD, however I’ve read the FMOD Designer’s API tutorial and also the manpage for EventGroup::getEvent() which provides some info about the way memory is managed for Event instances, however I’m still a little fuzzy. If someone could confirm or deny the following it would be much appreciated:
A pool of Event objects is allocated when you call EventProject::getGroup(), and subsequent calls to EventGroup::getEvent() return pointers to these already-allocated Events … i.e. except for possibly loading FSB data because caching wasn’t turned on, getEvent() shouldn’t result in any more memory being allocated.
Assuming the above is true, it is safe to keep calling getEvent() till the cows come home on a particular EventGroup and you will never run out of memory because the objects in the pool are just recycled and no new ones are actually allocated.
When you are done with a particular EventGroup (i.e. you change levels or whatever) you need to call EventGroup::freeEventData( NULL ) to clean up all the FSB data as well as the Event instance pool. At this point all memory allocated by FMOD since the first call to getGroup() has been cleaned up.
Basically, I’m trying to figure out whether I need to delete Event*’s at any point. It doesn’t seem like I need to, but I just need to know that the memory for the Event objects is being automatically cleaned up by FMOD. I’m pretty sure the memory for the wave data is being dealt with, but just not sure about the Event objects.
Any comments and corrections would be much appreciated.
- glenc asked 12 years ago
You’ve pretty much got it there Glen. You don’t need to delete events at any time. getEvent won’t keep on allocating memory, FMOD pre-allocates however many instances you specify in "Max playbacks" in the designer tool. If you getEvent more than that amount then FMOD will steal an already playing event.
Also note that getEvent will only load the wavedata required for that specific event, not all events in the group. Also, freeEventData takes an Event * parameter so you can free wavedata for a specific event too. This allows you to have "random access" loading of events. Of course this is moot if you’ve already called loadEventData which loads wavedata for all events in the group.
Please login first to submit.