[Interest] memory fragmentation?

Jason H scorp1us at yahoo.com
Wed Aug 22 15:19:56 CEST 2012


This seems like it would be slow, especially when you started using haddrist swap space, unless you have that turned off. I think that it would be better to just check against a limit yourself as to avoid allocating items that would be swapped.* 

*I have no idea how your application uses the cache.





________________________________
 From: Graeme Gill <graeme2 at argyllcms.com>
To: interest at qt-project.org 
Sent: Tuesday, August 21, 2012 11:45 PM
Subject: Re: [Interest] memory fragmentation?
 
Till Oliver Knoll wrote:
> Folks, I gave up checking for NULL pointers (C, malloc) or bad_alloc 
> exceptions (new, C++) a long time ago. I remember a discussion several 
> years ago (here on Qt interest?) about desktop memory managers actually 
> never returning a NULL pointer (or throwing an exception) when they 
> cannot allocate memory.

This is simply not true when it comes to malloc. Malloc can and does
return NULL on MSWin, OS X and Linux. I have some code that
uses as much RAM as possible for computation caching, and the simplest
portable way of sizing the virtual memory space is to malloc memory
until it returns NULL, and then constrain the cache to be smaller
than the available physical RAM and virtual memory space.
[On 32 bit systems it is now common to have more RAM that
virtual memory space.]
Even when operating below that limit, the cache can get a NULL (due
to fragmentation or mallocs outside the caches purview), and responds
by freeing up cache memory until the malloc succeeds.

Graeme Gill.
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120822/76310c10/attachment.html>


More information about the Interest mailing list