VisualGestureBuilder框架阅读器内存泄漏? [英] Memory Leak in VisualGestureBuilder frame reader?
问题描述
我注意到VisualGestureBuilder功能中存在内存泄漏。一旦读者打开内存泄漏。我测试了我的应用程序过夜,它使用了超过250 MB的内存(从大约10 MB开始)。由于我的手势应用程序应该全天候运行,
它会在某个时刻崩溃...
Hi, I noticed a memory leak in the VisualGestureBuilder functionality. As soon as the reader is opened memory leaks. I tested my application over night and it used over 250 MB memory (starting at about 10 MB). Since my gesture application should run 24/7, it will crash at some point...
它甚至发生在这个简单的例子中:
It even happens in this simple example:
GetDefaultKinectSensor( &_sensor );
_sensor->Open();
CreateVisualGestureBuilderFrameSource( _sensor, 0, &_gestureSource );
_gestureSource->OpenReader( &_gestureReader );
while (1) {
if( cv::waitKey( 1 ) == 27)
break;
}
有这个问题的解决方案吗?我只使用一个手势帧阅读器并将跟踪ID设置为当前正在进行交互的用户。
Is there a solution to this problem? I only use a single gesture frame reader and set the tracking id to the currently interacting user.
推荐答案
就像所有其他帧类型一样,上面提供的代码将在您创建VisualGestureBuilderFrameSource时分配内存,打开VisualGestureFrameReader,并接收VisualGestureBuilderFrame。
Just like with every other frame type, the code you provided above will allocate memory when you create the VisualGestureBuilderFrameSource, open the VisualGestureFrameReader, and receive a VisualGestureBuilderFrame.
打开源代码和阅读器应该在您的构造函数或其他初始化块中完成一次。 这将只分配一次必要的内存。 当您获得新的跟踪ID时,您可以将其应用于先前分配的来源
,而不是创建新的来源。
Opening the source and reader should be done once in your constructor or some other initialization block. This will allocate the necessary memory just once. When you get a new tracking id, you can apply it to the previously allocated source rather than creating a new source.
每次获得一个框架时,您都应该确定在使用后将其丢弃。
Every time you get a frame, you should be sure to dispose of it after it has been used.
这篇关于VisualGestureBuilder框架阅读器内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!