Memory leak with SVO2 recording

Hello, I’m currently using the ZED X camera on jetson devices. I’m seeing a memory leak while running a modified version of the C++ example recording code for single camera.
Attaching the main function used below:

int main(int argc, char **argv) {

    int video_count = 0;

    // Create a ZED camera
    Camera zed;

    // Set configuration parameters for the ZED
    InitParameters init_parameters;
    init_parameters.depth_mode = DEPTH_MODE::NONE;
    init_parameters.camera_fps = 15;
    init_parameters.camera_resolution = RESOLUTION::HD1080;

    // Open the camera
    auto returned_state  = zed.open(init_parameters);
    if (returned_state != ERROR_CODE::SUCCESS) {
        print("Camera Open", returned_state, "Exit program.");
        return EXIT_FAILURE;
    }

    std::string base_name = "test";
    std::string file_name = base_name + std::to_string(video_count) + ".svo2";
    // Enable recording with the filename specified in argument
    RecordingParameters recording_parameters;
    recording_parameters.video_filename.set(file_name.c_str());
    recording_parameters.compression_mode = SVO_COMPRESSION_MODE::H265;
    returned_state = zed.enableRecording(recording_parameters);
    if (returned_state != ERROR_CODE::SUCCESS) {
        print("Recording ZED : ", returned_state);
        zed.close();
        return EXIT_FAILURE;
    }

    // Start recording SVO, stop with Ctrl-C command
    print("SVO is Recording, use Ctrl-C to stop." );
    SetCtrlHandler();
    sl::RecordingStatus rec_status;
    uint frame_count = 0;
    while (!exit_app) {
        if (zed.grab() == ERROR_CODE::SUCCESS) {
            frame_count++;
            if (frame_count == 10) {
                zed.disableRecording();
                video_count++;
                std::filesystem::remove(file_name);
                file_name = base_name + std::to_string(video_count) + ".svo2";
                recording_parameters.video_filename.set(file_name.c_str());
                frame_count = 0;
                zed.enableRecording(recording_parameters);
            }
        } else {
            continue;
        }
    }

    // Stop recording
    zed.disableRecording();
    zed.close();
    return EXIT_SUCCESS;
}

The memory leak is much more serious when using SVO_COMPRESSION_MODE::H265. With SVO_COMPRESSION_MODE::H264 the leak is minor but still exists. With SVO_COMPRESSION_MODE::LOSELESS, there seems like no leak.

Appending an image below with running top
image
The MEM usage quickly accumulates to 65.7% in roughly three and a half minutes. The device had 16GB RAM.

Hi @Yjin
Welcome to the StereoLabs community.

Please share information concerning your system setup

Hi MyZhar, thanks for the reply.
I’m currently running this on a ZED box orin nx 16GB.
The L4T version is 36.3 and I’m running the latest zed SDK which is 5.0.2.
I’ve tried with a ZED 2i and a ZED X camera, both has the same issue.

Hi @Yjin
Thank you for the information.

Please use a plot tool to monitor the live memory usage status (e.g. gnome-system-monitor) and verify that it effectively grows with no limitations in time.

Hi @Myzhar


The first process in the list is the recording process.
I can put only one image in a single post, the graph will be appended in the next post.

1 Like


Then RAM usage just accumulates while keeping this process open.

1 Like

Hi @Yjin
Thank you for the useful information.
I forwarded the details to the ZED SDK team.
A fix will be applied with one of the next releases of the ZED SDK.

Hi @Yjin
Thanks to your useful information, the team has already detected the issue and fixed the bug.
You will find the fix in the ZED SDK v5.0.3 that will be released soon.

1 Like