Re: memory fragmentation

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance





"Barry Schwarz" <schwarzb@xxxxxxxx> wrote in message news:2efpk49gmji4r2viotkp3g2bq3ai6frcuu@xxxxxxxxxx
On Fri, 19 Dec 2008 23:20:01 -0800, NianHawk
<NianHawk@xxxxxxxxxxxxxxxxxxx> wrote:

would frequent allocation and release of small buffers definitely cause
memory leaks? My application have to allocate small buffer for sending data
and then release it after it is done very frequently. I am not sure whether
it would cause memory fragmentation and thus poor performance? Your help
would be appreciated.

Why or how do you think memory fragmentation would cause poor
performance?

Because there are more blocks for the heap manager to keep track of? I doubt the heap algorithms are O(N), but I also doubt they are O(1).

In addition, heap allocation and deallocation are fairly slow operations which additionally require obtaining a global lock. So it's best to reuse buffers internally instead of freeing and reallocating, if possible.


--
Remove del for email

.



Relevant Pages

  • Re: How to PostMessage with a string parameter?
    ... > How do I post a message with a string parameter? ... You can allocate a buffer on the heap and send the pointer cast to ...
    (microsoft.public.vc.atl)
  • Re: Inline Assembly - Runtime Stack Allocation
    ... > not allocate it on the heap. ... think of it, since you're using this space only as a transfer buffer, ...
    (comp.lang.c)
  • Re: Runtime stack allocation
    ... I'd rather not waste space or dynamically allocate on the heap (since ... //INLINED (Intel p4 assembly) ... //do some stuff with the temporary buffer, ...
    (comp.lang.c)
  • Re: Kernel malloc/realloc?
    ... No, it can't guarantees that the memory is not moved in physical, because as ... If you alloc 4K then you grow the buffer, no coppy will be made, this is my ... Even better, on application side, you can allways allocate multiples of 4K ...
    (microsoft.public.development.device.drivers)
  • [PATCH] cpm_uart: Fix dpram allocation and non-console uarts
    ... Makes non-console UART work on both 8xx and 82xx ... static unsigned int cpm_uart_tx_empty(struct uart_port *port) ... /* Write back buffer pointer */ ... * Allocate DP-Ram and memory buffers. ...
    (Linux-Kernel)