SharedMemory: How fast is attach and detach?



  • Hi all,

    Consider the following situation:
    I have a program A which creates a shared memory, and a program B which attaches the shared memory.
    Now, when program A is closed, program B is still attached to the shared memory. When program A is restartet, it cannot create the shared memory because B is still attached.
    To avoid this problem, program B could attach and detach the shared memory every time it wants to read data.
    And here is my question: How fast is attaching and detaching the shared memory, because reading out some data in my program should happen 100 times per second and faster.

    regards
    Oliver


  • Lifetime Qt Champion

    Hi,

    You should benchmark. That will depend on several factors so you should test the speed yourself.


  • Moderators

    @stvokr said in SharedMemory: How fast is attach and detach?:

    To avoid this problem, program B could attach and detach the shared memory every time it wants to read data.

    Or program A could first check if the shared memory segment exists (by trying to attach to it) and only if that fails with QSharedMemory::NotFound error it would create it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.