On 2004-10-16 14:02-0500 mjl@... wrote:
> XOpenDisplay() does appear to be the first call, in the X driver at least
> (except for XInitThreads, but that's a special case). I'm not sure if there's
> any absolute requirement that XOpenDisplay() come first -- the man page
> doesn't say -- although obviously there's not much you can do until you have
> a display pointer.
Thanks, Maurice, for your response. I mentioned XOpenDisplay because that
was in the call stack of Andrew's example, but the problem there must lie
elsewhere because I tried a simple test routine with XOpenDisplay (see
below), and it generates no memory management errors (except for some
software@...> cat test.c
software@...> gcc test.c -L/usr/X11R6/lib -lX11
software@...> valgrind ./a.out
==24048== Memcheck, a memory error detector for x86-linux.
==24048== Copyright (C) 2002-2004, and GNU GPL'd, by Julian Seward et al.
==24048== Using valgrind-2.2.0, a program supervision framework for x86-linux.
==24048== Copyright (C) 2000-2004, and GNU GPL'd, by Julian Seward et al.
==24048== For more details, rerun with: -v
==24048== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 17 from 1)
==24048== malloc/free: in use at exit: 27 bytes in 1 blocks.
==24048== malloc/free: 90 allocs, 89 frees, 24148 bytes allocated.
==24048== For a detailed leak analysis, rerun with: --leak-check=yes
==24048== For counts of detected errors, rerun with: -v
A better procedure is to look at the very first generated memory management
problem. (I believe the one involving XOpenDisplay was at least the second
or later found by Andrew's example). Going back to my own valgrind ./x10c
-dev xwin example, the call stack for the first detected memory management
problem includes an XAllocColor call so I think we should concentrate on
a simple example of that.
Maurice, would you be willing to use your X experience to expand test.c
above to include a call to XAllocColor to see if that always triggers the
memory management problem found by valgrind on all x86 X systems available to
us? Of course, I could just blindly follow what PLplot does to set up
XAllocColor, but that PLplot setup of XAllocColor may the source of the
problem in itself.
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project