For one thing, shared memory does not use an HDD, so it doesn't matter if you have 150 GB of disk space. It is memory-based.

Second, shared memory is allocated by the OS and is shared among processes. In your code, you allocate a new QSharedMemory instance (using new), but you never delete it when the program exits. If the shared memory segment named "foo" is still around, then you can't create a new one. If you are running multiple instances of your program, then the first time through it may be able to "create()" the segment, but the second running instance of the app can't because it already exists. You can "attach()" to it.

"Undefined error: 0"
The QSharedMemory docs say that an error code of 0 means "no error".