NDI iOS SDK leaking memory


New member
I have created a functionality for one of our iOS apps to select an NDI source and display the video on iPhone / iPad using NDI Advanced SDK v5 for Apple .
I discovered a steadily growing memory usage, so I investigated it by reducing the code to a minimum and checking the allocations with Instruments.
It turns out that for every video frame there is a 144 Byte memory block allocated that is not freed anymore. Sounds not much, but around 15 MB per hour (at 30 fps) is not nothing.

I do standard setup as in the examples:
• NDIlib_find_create_v2()
• NDIlib_find_get_current_sources()
• NDIlib_recv_create_v3() with format NDIlib_recv_color_format_RGBX_RGBA, allow_video_fields = true
• NDIlib_recv_connect
I can provide the full source if required.

My minimum loop doing nothing except to to call NDIlib_recv_capture_v2 (on its own thread):

- (void) receiveFrames
NDIlib_frame_type_e type = NDIlib_recv_capture_v2(pNDI_recv, NULL, NULL, NULL, 1000);

So, I don't request video, audio or meta data, but still there is this 144 Bytes leak. It is a call to CMBlockBufferCreateWithMemoryBlock from the library, to be exact:
Processing::NDI::Codecs::details::video_codec_impl::decode_h264::decode_packet(NDI_recv_video_header_v2 const&, std::__1::pair<unsigned char*, long>)

See screenshot of Instruments below.

I don't know whether this is the right place to post it. Hopefully someone from SDK team looks into it.



  • Screenshot_Instruments.png
    913.2 KB · Views: 38


Post-LW Engineer
So this also happens if you do get the video frame and free it with NDIlib_recv_free_video_v2() ?
I'm not a Mac developer, but at first glance it does look a buffer isn't being freed in the mac-specific h264 decoder. I suggest you contact [email protected] with your findings.

Top Bottom