Dropped frame. alloc_frame(...) returned nullptr
| Required Info | |
|---|---|
| Camera Model | D435, D415 |
| Firmware Version | 05.12.00.00 |
| Operating System & Version | Win 10 |
| Kernel Version (Linux Only) | --- |
| Platform | PC |
| SDK Version | 2.31.0 |
| Language | {C# |
| Segment | others |
Issue Description
Once migrated SDK versión from 2.11.1.0 to 2.31.0 and both with D435 or D415, after some seconds the WaitFormFrames() method fails throwing an exception of one of two kinds:
- "Error while running Colorizer processing block, check the log for info"
- Frame didn't arrived within 5000
In both cases, the error registered in realsense log is: 24/03 18:13:25,802 WARNING [12012] (types.cpp:49) Out of frame resources! 24/03 18:13:25,802 ERROR [12012] (synthetic-stream.cpp:47) Exception was thrown during user processing callback! 24/03 18:13:25,834 INFO [10528] (win-helpers.cpp:86) hr = spSample->GetUnknown(MFSampleExtension_CaptureMetadata, IID_PPV_ARGS(&spUnknown)) returned: HResult 0xc00d36e6: "No se encontró el atributo solicitado." 24/03 18:13:25,834 INFO [10528] (sensor.cpp:361) Dropped frame. alloc_frame(...) returned nullptr
It looks like errors only occurs if some Matrix operations are performed over short array data with Emgu.CV. The operations didn't change from SDK 2.11.1 (with that version worked properly), but with version 2.31.0 the camera fails once Matrix operations finish.
Data received from camera is cloned correctly in a deep what so no reference issue should occur.
Any suggestion?
Hi,
It seems nobody has a solution for this issue. Comparing both versions, it looks lie 2.31 SDK version doesn't work properly when memory consuption increases.
This is a compartive with both SDK versions (2.11.1 and 2.31):
With 2.31.0 SDK version, while application increases memory usage, when it raises 300Mb camera stops working:

With previous 2.11.1 SDK version, camera is still working properly even when memory usage raises to 800Mb:

Is there any condition in the latest SDK version that makes the camera stop working?
@amatabuena Did you get this issue with SDK examples? Also did you get any chance to try the latest SDK to see if the issue still existing?
Hi,
I've tried with SDK examples and the work fine. However, all exampled are coded in WPF, while I'm using WinForms. I have done tests with other version of SDK (not latest) and all version later than 2.11 raise the same error.
As from SDK 2.11.1 to latest versions one of the main changes was FrameReleaser, after doing a lot of tests, I have "discovered" that using FrameReleaser and/or applying colorizer with frame.ApplyFilter instead of colorizer.Process(frame) are both causing the error. This SDK never stops surprising me...
My conclusion is that SDK (C# Wrapper) internally does not release deep frame memory correctly in some cases, so when application calling SDK and using this deep frame requires more memory Intel SDK fails with not available resources.
So, this code works form me:
while (true)
{
//using (FramesReleaser releaser = new FramesReleaser())
{
using (var frames = pipeline.WaitForFrames())
{
var colorFrame = frames.ColorFrame.DisposeWith(frames);
var depthFrame = frames.DepthFrame.DisposeWith(frames);
// We colorize the depth frame for visualization purposes
//var colorizedDepthFrame = colorizer.Process<VideoFrame>(depthFrame).DisposeWith(frames);
var colorizedDepthFrame = depthFrame.ApplyFilter(colorizer).As<VideoFrame>().DisposeWith(frames);
Bitmap bmpColor = toBitmap(colorFrame, 0);
Bitmap bmpDepth = toBitmap(colorizedDepthFrame, 0);
this.Invoke(new Action(() => this.pictureBox1.Image = bmpColor));
this.Invoke(new Action(() => this.pictureBox2.Image = bmpDepth));
}
}
}
But this does not (Error while running Colorizer processing block, check the log for info):
while (true)
{
//using (FramesReleaser releaser = new FramesReleaser())
{
using (var frames = pipeline.WaitForFrames())
{
var colorFrame = frames.ColorFrame.DisposeWith(frames);
var depthFrame = frames.DepthFrame.DisposeWith(frames);
// We colorize the depth frame for visualization purposes
var colorizedDepthFrame = colorizer.Process<VideoFrame>(depthFrame).DisposeWith(frames);
//var colorizedDepthFrame = depthFrame.ApplyFilter(colorizer).As<VideoFrame>().DisposeWith(frames);
Bitmap bmpColor = toBitmap(colorFrame, 0);
Bitmap bmpDepth = toBitmap(colorizedDepthFrame, 0);
this.Invoke(new Action(() => this.pictureBox1.Image = bmpColor));
this.Invoke(new Action(() => this.pictureBox2.Image = bmpDepth));
}
}
}
}
This also fails:
while (true)
{
using (FramesReleaser releaser = new FramesReleaser())
{
using (var frames = pipeline.WaitForFrames())
{
var colorFrame = frames.ColorFrame.DisposeWith(releaser);
var depthFrame = frames.DepthFrame.DisposeWith(releaser);
// We colorize the depth frame for visualization purposes
//var colorizedDepthFrame = colorizer.Process<VideoFrame>(depthFrame).DisposeWith(frames);
var colorizedDepthFrame = depthFrame.ApplyFilter(colorizer).As<VideoFrame>().DisposeWith(releaser);
Bitmap bmpColor = toBitmap(colorFrame, 0);
Bitmap bmpDepth = toBitmap(colorizedDepthFrame, 0);
this.Invoke(new Action(() => this.pictureBox1.Image = bmpColor));
this.Invoke(new Action(() => this.pictureBox2.Image = bmpDepth));
}
}
}
Hi,
Some extra tests that confirms memory problems:
This line causes the camera capture to fail when using more memory:
var frameSet = frames.Clone().AsFrameSet();
And this line also causes the camera to fail:
var frameSet = frames.Clone().AsFrameSet().DisposeWith(frames);
But with this way it doesn't fail:
var frameSet = frames.Clone().DisposeWith(frames).AsFrameSet().DisposeWith(frames);
And the same situation occurs with any kind of casting such as .As
It looks like SDK creates intermediate objects that are not released if you don't put Disposewith() everywhere.
Thanks for your message.
I think you can try Frame.Keep() in your code. It's different method.
Hi,
How can frame.keep() resolve this memory problems?
Thanks,
@amatabuena Sorry for late reply. Did you still have issue with the latest SDK? Looking forward to your update. Thanks!
Hi,
The issue is still happening. I have mitigated forcing Garbage Collector to garbage memory every frame. (I know is not the best practise).
Thanks,
about FrameReleaser you can try this code.
using (var frames = pipeline.WaitForFrames())
{
using (var releaser = new FramesReleaser())
{
var colorFrame = frames.ColorFrame.DisposeWith(releaser);
var depthFrame = frames.DepthFrame.DisposeWith(releaser);
var colorizedDepth = depthFrame.ApplyFilter(colorizer).DisposeWith(releaser).As<VideoFrame>().DisposeWith(releaser);
// do something ...
}
}
more detail you can read the snippet https://github.com/IntelRealSense/librealsense/blob/master/wrappers/csharp/cs-tutorial-3-processing/Window.xaml.cs#L86-L103
BTW, when you want to call frames.Clone(), you may need frames.Keep(). You can't hold many frames in the same time for a long time. and make sure you have release all of frames. https://github.com/IntelRealSense/librealsense/blob/master/include/librealsense2/h/rs_frame.h#L190-L196
@amatabuena Did you get chance to try? Looking forward to your update. Thanks!
Hi,
I tried the solution suggested on July 10th, but the problem persists. Forcing Garbage Collector every time (I know, it is not a good practice) looks like solves the problem.
Thanks.
You are correct. In this case, it's some of memory handle by the wrapper. Please make sure there is no memory leak issue.