I am just getting started with the X11 windowing system. I am trying to make a simple hello world for OpenGL that does not leak memory.
I am currently developing in C++ on Ubuntu 12.04 running in a virtual machine with valgrind. In the past, I have had problems with valgrind reporting many false positive errors in virtual machines, while not doing so on real ones.
I have tried a few simple OpenGL programs, but the one that I found most complete in terms of memory checking (this one), still leaks at least 25KB. I have not had the opportunity to test on a real machine, but given the simple nature of the program, I still suspect it is actually leaking and not a false positive (also I can dike out certain calls and it reports no leaks).
I am asking for a pointer to:
1: An exhaustive list of functions for X. I would like to answer my questions from the documentation. For example, Googling "XFree" will get you nowhere. I have been unable to find a complete documentation.
2: A trivial OpenGL program with an X backend that properly handles resources with no leaks. It can draw, like, a single triangle or something.
Thanks all!
-G
Making a Trivial X Windowing System Program that Doesn't Leak Memory like a Sieve
#1 Members - Reputation: 1029
Posted 09 February 2013 - 10:53 PM
#2 Members - Reputation: 379
Posted 10 February 2013 - 04:53 AM
It is much simpler.
If you are using c++, i suggest putting most things in a shared_ptr with the correct deleter function so you dont need to worry about manual memory management.
#3 Members - Reputation: 1029
Posted 10 February 2013 - 11:52 AM
Try this one http://www.opengl.org/wiki/Programming_OpenGL_in_Linux:_GLX_and_Xlib
That is indeed, a much nicer-looking code, and it works well with the virtual machine in windowed mode.
It still reports leaks, but this could be the virtual machine's doing again. I'll report back after testing on a real computer.
#4 Members - Reputation: 1029
Posted 12 February 2013 - 03:06 PM
I'll report back after testing on a real computer.
I continued development, and then tested it on a real Ubuntu platform. Even though the virtual machine reports leaks, Valgrind on the real machine reports none.
Thanks,






