PDA

View Full Version : My QPixmaps objects are null over a specific range of created objects ... why ?



yellowmat
18th July 2006, 17:39
Hi everybody,

I'm trying to fill a QCanvasPixmapArray with QCanvasPixmap but over a specific number of objets created (191 in ly case) the QCanvasPixmap are always null. I don't know why and it is blocking for me.

Here is my code :


for(int i =0; i<71; i++)
{
static QString fn;
fn = path + QString::number(i) + ".png";

QCanvasPixmap* pCanPix = new QCanvasPixmap(fn);
Q_ASSERT( pCanPix );
if( pCanPix->isNull() )
qDebug("%s is null", fn);
fullpixes->setImage(i, pCanPix);
}


Each image is 800x480 pixels.

Is there any limitation with the number of object reference it is possible to use ?

Thanks in advance

gfunk
18th July 2006, 18:04
Can you print out the value of fn to verify the path is correct?
If that doesn't help, have you tried stepping into the code of the QCanvasPixmap constructor?

wysota
18th July 2006, 18:10
192 pixmaps with 800x480 pixels each in 24bits of colour give us:

800x480x3x192 = 221 184 000 bytes = 210MB

Maybe that's the reason? That you're out of memory somewhere (some OS limitation maybe)?

BTW. If using 8b alpha channel this increases to 281MB.

yellowmat
18th July 2006, 20:32
gfunk, no need to print fn because it is correct. The first 190 pixmap are loaded and can be displayed the others are null and problematic :)

wysota, I thought that the origin of my problem could be a memory overflow due to a limitation (OS or other) but I am not able to be sure, so I must find a solution to my problem. I can't change the pixmaps and keep them encoded in 24 bit.

Thanks for your help.

wysota
18th July 2006, 20:33
Maybe you don't need >190 pixmaps loaded into memory all the time?

yellowmat
18th July 2006, 20:53
That's true Wysota. I can load the big pixmaps in memory (those whose definition is 800x480) and the others can be loaded during on the fly.

I have another informations to give about my problem, I have 1Go of RAM (OS Windows NT, VisualC++ 6.0, QT3.3.3.) and when I look at the performance in the task manager, the memory seems not to be full. Maybe the limitation does not concern the memory but the number of pixmap handled ? It will surprise me because I'm using canvas and the documentation tell that it can manage many and many objects at a time.

I'm trying to find out some similar information over internet ... I am alone for the moment with this problem and until I find the cause of my bug I can't progress.

I'll be happy If you have some more information or if you can reproduce the problem

wysota
18th July 2006, 21:04
That's true Wysota. I can load the big pixmaps in memory (those whose definition is 800x480) and the others can be loaded during on the fly.
Or you can keep the small ones in memory and load the big ones on demand :)


I have another informations to give about my problem, I have 1Go of RAM (OS Windows NT, VisualC++ 6.0, QT3.3.3.) and when I look at the performance in the task manager, the memory seems not to be full.
That doesn't mean anything. The limitation may sit somewhere in Qt or in the underlying OS (for example in its GUI module).


Maybe the limitation does not concern the memory but the number of pixmap handled ? It will surprise me because I'm using canvas and the documentation tell that it can manage many and many objects at a time.
Objects -- yes, but they don't have to all consist of huge pixmaps, right?


I'm trying to find out some similar information over internet ... I am alone for the moment with this problem and until I find the cause of my bug I can't progress.
I'd subclass QCanvasSprite and make it load the data dynamically. Do you really need more than 190 frames of animation?

yellowmat
18th July 2006, 21:33
I need to keep the big pixmaps in memory because some of them (about 10 pixmaps) they must be displayed every 50 ms. The smallest pixmaps need not to be displayed as fast.

My animation is based on about 140 pixmaps and represents a menu, some of the pixmaps are used to play an animation to set the current item in focus and the others to pass the focus from an item to another.

I found some information about my problem, here are two links if you want to take a look.


http://lists.trolltech.com/qt-interest/2002-01/thread00014-0.html
http://lists.trolltech.com/qt-interest/2005-04/thread00395-0.html

It is said that the use of QPixmap could lead to OS limitation and instead it is better to use QImage ... so I'll check my code and try to change QPixmap with QImage. As I use Windows OS ... QPixmap is coupled to the HBITMAP limitation.

I need to investigate some more ... and will keep here a trace of my results.