Out of window IDs

hello, sometimes I get the attached notification from my wxpython app during usage. The GUI uses agw.aui and the user may open dialogs several times to interact with data.

My question is: how can I find the root cause of this problem and avoid it? The message says nothing about the component that exhausts the IDs. Is there a way to get an exception with a code context instead of a polite but little useful message like this?outofwinids

thanks in advance


The error message is coming from here: https://github.com/wxWidgets/wxWidgets/blob/1ace3b336e3470c5d1a097feea719293f6133f27/src/common/windowid.cpp#L242

Unfortunately, since it’s a log message we can’t automatically turn it into an exception. You may be able to do something similar by creating your own wx.Log target and catching the logging of the error there.

Does your application create tens of thousands of widgets? The auto ID manager is given a range of -30000 to -2000 for the IDs it is able to provide. IIUC, when a widget is destroyed then it should unreserve the ID so it can be reused later. Is it possible that you are recreating lots of widgets without actually disposing of the old instances when you are done with them?

I’m not certain this is your problem, but I had a similar problem a few years ago. It turned out that Windows had a global restriction on the number of IDs. My app use about 1000 IDs but some other app (I think it was a Norton ecurity program) was using many thousands. This meant that my app failed on machines that were running the Norton security program. I found some utility that let me see how many IDs were used by each app, but I don’t recall which one that was.

I try to clarify the context and the use case

  • the user sees the error message after using the application for one hour or more. Using the app means changing data from the gui and running calculations on the data model (more or less 10k records to be updated in the db behind the GUI)
  • after the error/log message has appeared I’ve been able to open the widget inspection tool to see if there are 30000 controls or so in some branch of the controls tree: there aren’t
  • the GUI has an agw.auibook with 7 pages. In 6 of them there are wx.grids and in 2 of them there are also graphical parts using wx.pseudodc. One of these DC is a gantt chart that can contain up to 700 shapes with their id

I think that the ids of the grids’ cells don’t create problems because I use many of them also in other context without this kind of errors. I have doubts about the usage (reserve/unreserve) of the ids of the gantt shapes when the dc is refreshed to show changes to the data

I was using self.GetParent().NewControlId() the create the ids of the shapes. Changing it to wx.NewIdRef() as in pseudodc demo can make the difference? is it mandatory to use a wx id generator or can I use another one? (the gantt bars refers to records of the db that have their own ids)

thank you for your time


It appears to me that wx.PseudoDC expects ids to be integers, but it is nowhere specified (as far as I can see) that they need to be actual wxWidgets/Windows IDs…

Maybe you can just try and use normal Python integers and see what happens. I am unclear on why wx.PseudoDC would ever need actual wxWidgets/Windows IDs, the shapes are not real controls…