tags:

views:

88

answers:

2

I have just started using QPixmapCache and I was wondering, since there is not much documentation, about how to adjust the size based on the system the application is running on.

Some users might have lots of free memory while others have very little. I have no idea what the best setting would be.

What would be the best way to detect the system (free) RAM and adjust the cache size to fit?

http://doc.trolltech.com/4.4/qpixmapcache.html#setCacheLimit

+1  A: 

To detect free RAM in Windows, you can use the GlobalMemoryStatus function.

I'm not sure if this will help you size the pixmap cache; perhaps you will need to do some performance measurements and create a lookup table.

sep
A: 

Note that QPixmap is window-system specific. This means that QPixmap likely corresponds to graphics card memory more than the general RAM. Just like any other cache, the size of it should "as much as it needs to be, but not more".

The best way to tune the cache is to profile your application running on a typical machine (of the target users). See if the cache starts to trash old pixmaps and get cache misses.

Ariya Hidayat