Fmod memory management traps

Source: Internet
Author: User

I recently encountered a memory leak. I checked it and found it in the fmod module.

If it weren't for all other components to customize the memory allocation function, I wouldn't doubt it.

Use fmod: EventSystem: getmemoryinfo () to output the memory information. It crashes, MB ~ 200 MB

I used xact before, and fmod thought it was similar, so I didn't care much about it.

I read the document in detail and found that there are three points:

  • Fmod: memory_initialize
    • You can replace the fmod memory distributor with your own memory to conveniently measure the internal usage of each module.
    • This function must be linked to the fmodex Lib, which is not applicable only to the Lib of the fmod event.
    • This step is optional, but our memory analysis tool is better at analyzing the memory module allocation, so we have customized it.
  • Fmod: Event
    • The playing sound will allocate some memory. If you do not recycle it, fmod will not be released unless you unload the entire project (. FEV ).
    • Generally, level-based Games use the management of switching projects, which is not very suitable for mmog. Therefore, you still need to regularly use fmod: eventgroup: freeeventdata () for memory reclaim.
    • The original code is really messy, so I can't stand to rewrite it. Change it to recycle it based on reference count and playback status.
  • Soundbank
    • This is similar to xact. Generally, sound effects are directly loaded into memory (memory), and background music is streamed (Stream)
    • In order to save disk and memory usage, encoding and compression are generally performed. I am used to using ADPCM for sound effects, MP3/xwma for music, and CPU decoding (which can be directly supported by hardware) can be ignored.
    • Fmod has an additional loading method: "decompress into memory ". decompress the compressed audio data to the memory for playback. you need to know that the extracted background music has dozens of MB...
    • Check that our soundbank was set to "decompress into memory", and the audio project was created by a program, so it would be better for the production staff to fill in the data -_-!
    • I made an agreement with the sound engineer: The sound effect uses "load into memory" + "ADPCM", and the music uses "stream from disk" + "MP3"
After the above changes, the memory occupied by fmod in normal games is usually about 3 MB, and the peak of fierce combat traffic will not exceed 10 MB. In a short time, it will be recycled back.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.