Max number of Xorg clients reached on repeated calls to Image::draw(Drawable). #5779
-
I have an app that makes repeated calls to the MagickImage::draw(Drawable) method. The Drawable is DrawableText, which is using an X11 font. After a number of calls to this method, the app eventually exits with the following message:
Tracing through the code, and adding debug to confirm, I see that the call to Image::draw eventually calls XRenderImage, which makes a call to XOpenDisplay, but no corresponding call to XCloseDisplay is made. I'm using and looking at the code for release 7.1.0-52. The stack that reaches that call is
Question 1) Is this a bug? As a note, the app is able to draw 64 times before exiting, and this matches the maximum number of Xorg server clients on my workstation. So it appears that reaching the maximum number of allowable X server clients is the problem. I can configure the X server to allow more connections, but the limit is still eventually hit.) In the code, I see a couple of places where calls to XFreeResources are made, but they appear to be only for error handling cases. I did add a call to XFreeResources before returning from XRenderImage (xwindow.c), and initially this did not help. On further debugging, I found that I also had to make the following change in the same XRenderImage method:
With these changes, my app gets a little further. But it still eventually hits the error. I think the issue there is that the X server is somewhat slow in processing XCloseDisplay calls relative to the frequency that my app is calling Image::draw, and so the limit on number of client connections to the X server is still eventually reached. Question 2) This particular app was working fine when using an earlier version of ImageMagick, namely 6.7.8-10. Inspecting the code from 6.7.8-10, it appears to also not call XCloseDisplay to offset XOpenDisplay. So I'm puzzled as to why the problem does not also occur on this older system. For various reasons I'm unable to debug the behavior on this older system. I realize you may not have enough information to answer this next question, but can you see or imagine any reason why the above problem does not occur when using 6.7.8-10 versus 7.1.0-52? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
We'll have patch in the main branch in about an hour. Download it and let's us know if you have any further issues. |
Beta Was this translation helpful? Give feedback.
We'll have patch in the main branch in about an hour. Download it and let's us know if you have any further issues.