【发布时间】:2014-08-19 22:48:17
【问题描述】:
这个程序:
#include <iostream>
#include <SDL2/SDL.h>
/*
* Lesson 0: Test to make sure SDL is setup properly
*/
int main(int argc, char** argv){
if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
SDL_Quit();
return 0;
}
使用g++ -o main main.cpp -lSDL2; valgrind ./main 编译产生以下输出:
==21646== HEAP SUMMARY:
==21646== in use at exit: 108,320 bytes in 582 blocks
==21646== total heap usage: 16,412 allocs, 15,830 frees, 106,043,200 bytes allocated
==21646==
==21646== LEAK SUMMARY:
==21646== definitely lost: 12,058 bytes in 4 blocks
==21646== indirectly lost: 0 bytes in 0 blocks
==21646== possibly lost: 0 bytes in 0 blocks
==21646== still reachable: 96,262 bytes in 578 blocks
==21646== suppressed: 0 bytes in 0 blocks
这是我应该担心的事情吗?如果是,我如何知道代码中误报和实际错误之间的区别?
【问题讨论】:
标签: c++ memory-leaks sdl valgrind