# Memory leak with SVO2 recording

**URL:** <https://community.stereolabs.com/t/memory-leak-with-svo2-recording/9157>\
**Category:** C++\
**Tags:** sdk, jetson\
**Created:** [June 25, 2025, 7:42am UTC](https://community.stereolabs.com/t/memory-leak-with-svo2-recording/9157 "2025-06-25T07:42:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yjin](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/y/8797f3/32.png) [@Yjin](https://community.stereolabs.com/u/Yjin)\
**Post date:** [June 25, 2025, 7:42am UTC](https://community.stereolabs.com/t/memory-leak-with-svo2-recording/9157/1 "2025-06-25T07:42:32Z")

</div>

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](https://community.stereolabs.com/uploads/default/original/2X/3/354c7847fb4f117654e13f76e4e4da6d01db68e1.png)  
The MEM usage quickly accumulates to 65.7% in roughly three and a half minutes. The device had 16GB RAM.

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [June 25, 2025, 7:48am UTC](https://community.stereolabs.com/t/memory-leak-with-svo2-recording/9157/2 "2025-06-25T07:48:39Z")

</div>

Hi @Yjin  
Welcome to the [StereoLabs](https://www.stereolabs.com/) community.

Please share information concerning your system setup

---

<div class="post-metadata">

**Author:** ![Yjin](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/y/8797f3/32.png) [@Yjin](https://community.stereolabs.com/u/Yjin)\
**Post date:** [June 26, 2025, 3:27am UTC](https://community.stereolabs.com/t/memory-leak-with-svo2-recording/9157/3 "2025-06-26T03:27:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [June 26, 2025, 8:50am UTC](https://community.stereolabs.com/t/memory-leak-with-svo2-recording/9157/4 "2025-06-26T08:50:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Yjin](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/y/8797f3/32.png) [@Yjin](https://community.stereolabs.com/u/Yjin)\
**Post date:** [June 27, 2025, 12:44am UTC](https://community.stereolabs.com/t/memory-leak-with-svo2-recording/9157/5 "2025-06-27T00:44:25Z")

</div>

Hi @Myzhar

 ![process](https://community.stereolabs.com/uploads/default/original/2X/2/216dc9db0140582f9b2338ac537cedaea02ce2f2.png)  
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.

---

<div class="post-metadata">

**Author:** ![Yjin](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/y/8797f3/32.png) [@Yjin](https://community.stereolabs.com/u/Yjin)\
**Post date:** [June 27, 2025, 12:44am UTC](https://community.stereolabs.com/t/memory-leak-with-svo2-recording/9157/6 "2025-06-27T00:44:57Z")

</div>

![memusage](https://community.stereolabs.com/uploads/default/original/2X/a/a7bffd9cf319639274716a0310c63fb228ea784c.png)  
Then RAM usage just accumulates while keeping this process open.

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [June 27, 2025, 9:12am UTC](https://community.stereolabs.com/t/memory-leak-with-svo2-recording/9157/7 "2025-06-27T09:12:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [June 27, 2025, 2:45pm UTC](https://community.stereolabs.com/t/memory-leak-with-svo2-recording/9157/8 "2025-06-27T14:45:30Z")

</div>

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.
