gtreshchev / RuntimeAudioImporter

Runtime Audio Importer plugin for Unreal Engine. Importing audio of various formats at runtime.
MIT License
308 stars 67 forks source link

URuntimeAudioUtilities::GetAudioHeaderInfoFromFile does not release memory #71

Closed yui-3 closed 6 days ago

yui-3 commented 6 days ago

I've been waiting for a long time but it's still not released

gtreshchev commented 6 days ago

Can you please share more context about the issue? Are there any particular areas where you notice the memory leak?

yui-3 commented 6 days ago

Can you please share more context about the issue? Are there any particular areas where you notice the memory leak?

just execute these bp nodes several times, then it should be possible to reproduce image

LogAudio: Warning: FVorbisAudioInfo::ReadCompressedInfo, ov_open_callbacks error code: -132 : OV_ENOTVORBIS
LogAudio: Error: Failed to parse header for compressed vorbis file.
LogRuntimeAudioImporter: Error: Unable to initialize WAV Decoder
LogRuntimeAudioImporter: Retrieving header information for MP3 audio format.
Encoded audio info: Validity of audio data in memory: Valid, audio data size: 61419562, audio format: ERuntimeAudioFormat::Mp3
LogAudio: Warning: FVorbisAudioInfo::ReadCompressedInfo, ov_open_callbacks error code: -132 : OV_ENOTVORBIS
LogAudio: Error: Failed to parse header for compressed vorbis file.
LogRuntimeAudioImporter: Error: Unable to initialize WAV Decoder
LogRuntimeAudioImporter: Retrieving header information for MP3 audio format.
Encoded audio info: Validity of audio data in memory: Valid, audio data size: 61419562, audio format: ERuntimeAudioFormat::Mp3
LogAudio: Warning: FVorbisAudioInfo::ReadCompressedInfo, ov_open_callbacks error code: -132 : OV_ENOTVORBIS
LogAudio: Error: Failed to parse header for compressed vorbis file.
LogRuntimeAudioImporter: Error: Unable to initialize WAV Decoder
LogRuntimeAudioImporter: Retrieving header information for MP3 audio format.
Encoded audio info: Validity of audio data in memory: Valid, audio data size: 61419562, audio format: ERuntimeAudioFormat::Mp3
LogAudio: Warning: FVorbisAudioInfo::ReadCompressedInfo, ov_open_callbacks error code: -132 : OV_ENOTVORBIS
LogAudio: Error: Failed to parse header for compressed vorbis file.
LogRuntimeAudioImporter: Error: Unable to initialize WAV Decoder
LogRuntimeAudioImporter: Retrieving header information for MP3 audio format.
Encoded audio info: Validity of audio data in memory: Valid, audio data size: 61419562, audio format: ERuntimeAudioFormat::Mp3
LogAudio: Warning: FVorbisAudioInfo::ReadCompressedInfo, ov_open_callbacks error code: -132 : OV_ENOTVORBIS
LogAudio: Error: Failed to parse header for compressed vorbis file.
LogRuntimeAudioImporter: Error: Unable to initialize WAV Decoder
LogRuntimeAudioImporter: Retrieving header information for MP3 audio format.
Encoded audio info: Validity of audio data in memory: Valid, audio data size: 61419562, audio format: ERuntimeAudioFormat::Mp3
LogRuntimeAudioImporter: Successfully retrieved header information for MP3 audio format.
Header info: Duration: 1536.783691, number of channels: 2, sample rate: 44100, PCM data size: 135544320, audio format: ERuntimeAudioFormat::Mp3
LogBlueprintUserMessages: [SoundPlayerLevel_C_0] 1536.783691
LogRuntimeAudioImporter: Successfully retrieved header information for MP3 audio format.
Header info: Duration: 1536.783691, number of channels: 2, sample rate: 44100, PCM data size: 135544320, audio format: ERuntimeAudioFormat::Mp3
LogBlueprintUserMessages: [SoundPlayerLevel_C_0] 1536.783691
LogRuntimeAudioImporter: Successfully retrieved header information for MP3 audio format.
Header info: Duration: 1536.783691, number of channels: 2, sample rate: 44100, PCM data size: 135544320, audio format: ERuntimeAudioFormat::Mp3
LogBlueprintUserMessages: [SoundPlayerLevel_C_0] 1536.783691
LogRuntimeAudioImporter: Successfully retrieved header information for MP3 audio format.
Header info: Duration: 1536.783691, number of channels: 2, sample rate: 44100, PCM data size: 135544320, audio format: ERuntimeAudioFormat::Mp3
LogBlueprintUserMessages: [SoundPlayerLevel_C_0] 1536.783691
LogRuntimeAudioImporter: Successfully retrieved header information for MP3 audio format.
Header info: Duration: 1536.783691, number of channels: 2, sample rate: 44100, PCM data size: 135544320, audio format: ERuntimeAudioFormat::Mp3
LogBlueprintUserMessages: [SoundPlayerLevel_C_0] 1536.783691
gtreshchev commented 6 days ago

There don't seem to be any issues. Based on your logs, it goes through the codecs to find the suitable one (which is why you have entries like FVorbisAudioInfo::ReadCompressedInfo, ov_open_callbacks error code: -132 : OV_ENOTVORBIS), and then eventually finds the right codec and returns the header info.

It looks like you execute GetAudioHeaderInfoFromFile multiple times, which is why you have repeated logs.

Is there anything in particular you meant when mentioning that the function does not release memory?

yui-3 commented 6 days ago

There don't seem to be any issues. Based on your logs, it goes through the codecs to find the suitable one (which is why you have entries like FVorbisAudioInfo::ReadCompressedInfo, ov_open_callbacks error code: -132 : OV_ENOTVORBIS), and then eventually finds the right codec and returns the header info.

It looks like you execute GetAudioHeaderInfoFromFile multiple times, which is why you have repeated logs.

Is there anything in particular you meant when mentioning that the function does not release memory?

After executing the function several times, the engine memory increased by about 5GB. Then, I waited for several GC cycles, and it was never GC

gtreshchev commented 6 days ago

There's a small bug in FMP3_RuntimeCodec::GetHeaderInfo when using the new minimp3 (default) codec, which doesn't free the memory. Thanks for letting me know! I'll fix it shortly

gtreshchev commented 6 days ago

Should be fixed in c68b15b905ea4bffc919bd44b2ea6293de94079e. Please let me know if you can reproduce any memory leaks starting from that update :)

yui-3 commented 6 days ago

@gtreshchev

Should be fixed in c68b15b. Please let me know if you can reproduce any memory leaks starting from that update :)

Thanks a lot, completely fixed👍