PDA

View Full Version : Does Qt support shared memory ?



Shawn
8th September 2007, 01:45
Does Qt support shared memory ?
Cause I need to use it.

marcel
8th September 2007, 03:14
Bee more explicit!
What do you need it for?

Shawn
8th September 2007, 04:03
I need to use shared memory, and i am using qt, I can not find any information in the assitant or examples shows how to used it.

But actually I remember clearly that once I saw something about the QSharedMemory. I tried to find it in the Assitant but failed...

marcel
8th September 2007, 04:53
I don't know what you mean.
For implementing implicitly shared classes you have QSharedData and QSharedPointer.

But you say "shared" memory. Shared by what? Threads?

Regards

Shawn
8th September 2007, 05:05
"Shared Memory is an efficeint means of passing data between programs. One program will create a memory portion which other processes (if permitted) can access. "

maybe this can help you understand me.

the shared memory segment will be accessed by two applications and thus implement the communication between them.

marcel
8th September 2007, 05:12
Oh, you meant shared by processes. I missed that option :).
In that case you must be referring to QSharedMemory available in Qt 4.4 :). See this link:http://doc.trolltech.com/main-snapshot/ipc-sharedmemory.html.

Anyway, until Qt 4.4 you will have to implement this using platform specific IPC mechanisms( named pipes, sockets, etc).

You can get started with these examples for windows: http://www.codeproject.com/threads/Win32IPC.asp

Also, for linux: http://tldp.org/LDP/lpg/node7.html.

You can find more with google. That's just to get you started.

Regards

wysota
8th September 2007, 08:27
You can always use shared memory functions available in the API of your platform. Using Qt doesn't restrict you from using other function calls.

Shawn
8th September 2007, 08:43
Yes, you are right.

I've found CreateFileMapping()...

Thanks for your time ~

sriky27
3rd November 2009, 13:05
Hi,

this may sound stupid but is it possible to share the pointer from http://qt.nokia.com/doc/4.6-snapshot/qshareddatapointer.html between two different processes.

Regards,
Sriky

wysota
3rd November 2009, 13:26
No, it's not possible.

sriky27
3rd November 2009, 14:18
Hi guru,

What is the best and easiest way to do that. Currently we are following an approach where we serialize and deserialize data at three levels. I am trying to avoid it. Is QSharedMemory the best solution in terms of performance. when compared to serializationa and deserialization.

wysota
3rd November 2009, 17:07
It depends what you want to do. QSharedMemory works on byte level, so you will need to serialize and deserialize your data anyway.