Important: Please read the Qt Code of Conduct -

QSharedMemory handle issues (RHEL)

  • Hello -

    I have a very strange problem. Basically, I use a QSharedMemory segment (Qt 4.7) in order to share/push data out from my application's main window to child windows. The child windows attach to the same segment using a completely static text key, the same used by the main window when initially creating the shared memory segment (e.g. "memory_share_test"). While the main window creates the shared memory segment, the child windows only attach (as they are opened when needed), and read data from the shared memory as needed (in order to display updating data).

    By and large, this works fine. I can open/close child windows all day and not have any issues. However, if I go away for a few days (say, across a weekend, where my updating data source is effectively offline) and come back, the child windows that are already open will continue to be fine (they can continue to see the shared memory segment fine). But if I open a new child window after this period of inactivity, I can't attach to the shared memory segment from the (new) child windows - I get the error "QSharedMemory::handle:: UNIX key file doesn't exist". Again, the child windows that are already open are fine, but if I close them (and re-open them) I get the same error. It's as if - after some time - I can no longer attach to the shared memory segment using the text key. Shutting down the whole application and restarting it (forcing the main window to re-create the shared memory again) solves the issue.

    My gut instinct is that perhaps the OS (RHEL in this case) is doing some sort of housekeeping after a period of inactivity, perhaps corrupting the ability for any new child windows to find that shared memory segment in the future. Adding to this possibility, I have been running this same application on Linux Mint as well, and I have not seen this issue (at least yet).

    Any suggestions or insight would be much appreciated!



Log in to reply