texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] Scrolling speed


From: Dan Martens
Subject: Re: [Texmacs-dev] Scrolling speed
Date: Wed, 26 May 2004 20:40:24 -0400

>Any explanation for this phenomenon? Does malloc give me blocks which
>do not behave well from the cache point of view? Should I allocate
>larger consecutive blocks of memory? I currently allocate blocks of
>64Kb for small objects. Should I use larger blocks instead?
>Should I also use larger blocks for big mallocs?

If you are constantly allocating and deallocating blocks, your memory is going 
to get fragmented.  The more fragmented it gets, the more time malloc's search 
algorithm for best fit is going to take.  If your always deallocating and 
allocating the same size of blocks, this should not be a problem unless another 
program is allocating chunks of the recently deallocated blocks in which case 
it will then be too small to reclaim and malloc will have to keep searching.

Larger blocks will sometimes take more time to allocate if memory is full of 
small holes.  I would suggest only allocating larger blocks if you are going to 
do your own management of them. If you do require one large malloc, you should 
allocate the entire thing at once rather than in small chunks.

The best way to test if memory allocation is the problem is to print out the 
addresses of allocated blocks.  If they are always the same (malloc is 
reclaiming your own previously allocated memory), then the problem is not 
there.  If the addresses are always different, then it is definitely a memory 
problem.

Dan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]