PDA

View Full Version : Support for File Mapped Memory?



Jachyra
4th February 2007, 04:55
I just started using Qt 4.2 this week because I was finally able to convince my boss that Qt was a far superior framework than what we were using.

I'm trying to figure out the "Qt way" of implementing File Mapped Memory (MapViewOfFile on win32 and mmap I believe on linux). I've spent hours digging through the documentation and I've found classes for almost everything possible except for this.

Its pretty integral to our application so I'm hoping that this wasn't a major oversight on my part, but I just can't believe that this functionality wouldn't be available considering all of the other stuff that IS in there coupled with the fact that file mapped memory is becoming so integral to a lot of applications these days.

Thanks in advance for any responses.

wysota
4th February 2007, 10:01
http://www.qtcentre.org/forum/f-qt-programming-2/t-is-it-possible-to-memory-map-a-file-in-qt-4775.html

Jachyra
4th February 2007, 11:04
Well based on that link I guess Qt doesn't implement this....I find it a bit peculiar.

wysota
4th February 2007, 12:24
I find it a bit peculiar.

Really? Why so?

Jachyra
4th February 2007, 13:36
Well, just because there are classes in Qt for almost everything else imaginable, coupled with the fact that over the last year a lot of the various Microsoft developer bulletins that we get via our MSDN subscription has really sort of pushed memory maps as the best or "proper" way to implement projects that have very large data files.

wysota
4th February 2007, 15:37
Qt is a platform independent library and I think that in this particular situation memory mapping is different on different platforms, so it'd be a bit hard to provide a solution that work on all platforms in a simmilar way. Remember that someone has to write all the routines and there are surely more urgent things to do than to provide portable memory mappings.

Qt doesn't have to do everything, you can always use platform dependent solutions.

Jachyra
4th February 2007, 16:20
Well I appreciate the response but I'm not sure I really agree.

Jachyra
5th February 2007, 09:38
Ok, so it sounds like my only option then is to just write my own class to handle this. It looks like I can borrow some code from the link that was provided to implement it on linux, and I already know how to do it in win32. Assuming that I can get it working on linux, is it safe to assume that the same code will also work on Mac OS/X (Darwin), or am I going to have to go digging around in the Carbon API? For that matter, is Mac really even separate platform anymore or is it just linux with a proprietary window manager?

wysota
5th February 2007, 13:44
It's not safe to assume anything - I didn't even compile the code. In theory it should run but I give no warranty. mmap() is POSIX compliant, so it should work on all POSIX systems (notice the should word in both cases).