[Interest] memory fragmentation?
adriano.1.rezende at nokia.com
Tue Aug 21 14:41:15 CEST 2012
On 08/20/2012 05:51 PM, ext Jason H wrote:
> What can be done to combat this in C++/Qt?
> Initially I thought there might be some kind of QObject d-ptr magic
> where the large allocations can be in the private class and
> re-allocate and copy the private class, without affecting the pointers
> that the application uses. Then have a function that runs on a QObject
> tree, This does not fix the overall issue, but at least it could
> decrease the the chances of a failed allocation. But for me, this
> raises as many questions as it solves. Can we guarantee the new
> allocations are more compact than the old ones? That seems up to the
> heap manager. I don't know much about that. Also, when to run it?
> Periodically, or only when an allocation fails?
You will not solve the fragmentation issue in Qt itself, since there is
no good solution for general purpose but you can extremely reduce the
problem avoiding the fragmentation for the most critical parts of your
You can either use an object pool or a memory pool pattern, overloading
the new operator, but both approaches should be fined tuned for your
specific use case. I tend to use the former to handle sprites and
particles in some of my games.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest