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
The MEM usage quickly accumulates to 65.7% in roughly three and a half minutes. The device had 16GB RAM.