【发布时间】:2020-06-25 20:17:36
【问题描述】:
我用portaudio 编写了一些代码,并用Valgrind 对其进行了测试。结果,我得到“0字节肯定丢失”。但是,当我将它与 glut (freeglut) 库混合以包含图形时,我得到“肯定丢失了 24 个字节”。
在下面的代码中,我只是添加了glutCreateWindow( "OpenGL" ),然后我在 Valgrind 的报告中得到了内存泄漏。我正在使用 glew、freeglut、portaudio、sndfile 库。有谁知道这里发生了什么?
#include "util.h"
#include "sound.h"
#include <unistd.h>
/*Funcion main para creacion de hilos de reproduccion*/
int main(int argc, char* args[]){
sound::loadStream("../pacman.wav");// this function do Pa_Initiliaze()/Pa_OpenDefaultStream()/
//Pa_StartStream()/
sound::loadStream("../ya_te.wav");
glutInit( &argc, args );
//Create OpenGL 2.1 context
glutInitContextVersion( 2, 1 );
//Create Double Buffered and RGBA Window
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH );
glutInitWindowSize( 1920, 1080 ); //size of window
glutCreateWindow( "OpenGL" ); // leak memory start at this line
sound::changeState(0,PLAY); //this fucntion change pacman.wav state to PLAY in portaudio
//callback
sound::changeState(1,PLAY); // this function change ya_te.wav state to PLAY in portaudio
//callback
sleep(1); // sleep for 1 second
sound::soundTerminate(); // this function do Pa_closeStream , Pa_terminate();
glutDestroyWindow(glutGetWindow());
return 0;
}
【问题讨论】:
标签: c++ opengl valgrind freeglut portaudio