I'm making a Julia wrapper around Xlib and I don't know if the pointer to a Display
that I get from XOpenDisplay
has to be freed with XFree
. The documentation doesn't hint toward that but I want to be safe and be sure I'm not allowing a memleak. The same thing with Screen
and Visual
pointers that appear in several places in the library, do they have to be freed?
Asked
Active
Viewed 208 times
1

MasFlam
- 45
- 6
-
2`Display*` returned by `XOpenDisplay()` should be destroyed by `XCloseDisplay()`. Calling `XFree()` instead of `XCloseDisplay()` on `Display*` would certainly lead to memory leak and potentially might even crash. Which point in the documentation leads to confusion? – gkv311 Feb 11 '21 at 16:44
-
I knew I have to close it with `XCloseDisplay`, but I thought maybe the pointer doesn't get freed and only the display, well, closes. But I guess this makes sense, since what use would there be to leave a closed display (meta)data in memory. As far as which point confused me, it is just that the wording used in both `XOpenDisplay` and `XCloseDisplay` doesn't use the word "free", but only "close". Thanks for the comment-answer though :) – MasFlam Feb 11 '21 at 18:40