x265_encoder_open leaks memory (zoneParam are not released by x265_encoder_close)

Issue #616 new
Former user created an issue

Both prior version 3.4 as well as the latest stable x265-20220219 suffer from the same problem. Here is an output from valgrind:

==38148== 1,208 bytes in 1 blocks are definitely lost in loss record 15 of 18 ==38148== at 0x4848DD0: memalign (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==38148== by 0x4848F92: posix_memalign (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==38148== by 0x549CDE7: x265::x265_malloc(unsigned long) (common.cpp:83) ==38148== by 0x5028A82: x265_encoder_open_203 (api.cpp:98) ==38148== by 0x1E483C: mg_http_ws_callback (ws.c:783)

I have compiled the latest source code in the debug code. The line 98 in api.cpp points to "x265_param* zoneParam = PARAM_NS::x265_param_alloc();"

Somehow zoneParam is never released, which leads to memory leaks. Each pair of calls "x265_encoder_open" and "x265_encoder_close" simply increase the lost memory, losses accumulate. Over time memory leaks keep adding up in a server environment.

Comments (1)

  1. ザパート クリストファー

    Adding “PARAM_NS::x265_param_free(zoneParam);” just before “return encoder;“ at the end of the “x265_encoder_open” function fixes the memory leak.

  2. Log in to comment