Do you know how malloc works? The nature of malloc is that it has a long linked list of available blocks of memory called the free chain. When you call malloc, it walks the linked list looking for a block of memory that is big enough for your request. Then it cuts that block into two blocks — one the size you asked for, the other with the extra bytes, and gives you the block you asked for, and puts the leftover block (if any) back into the linked list. When you call free, it adds the block you freed onto the free chain. Eventually, the free chain gets chopped up into little pieces and you ask for a big piece and there are no big pieces available the size you want. So malloc calls a timeout and starts rummaging around the free chain, sorting things out, and merging adjacent small free blocks into larger blocks. This takes 3 1/2 days. The end result of all this mess is that the performance characteristic of malloc is that it's never very fast (it always walks the free chain), and sometimes, unpredictably, it's shockingly slow while it cleans up. (This is, incidentally, the same performance characteristic of garbage collected systems, surprise surprise, so all the claims people make about how garbage collection imposes a performance penalty are not entirely true, since typical malloc implementations had the same kind of performance penalty, albeit milder.)
http://www.joelonsoftware.com/articles/f...
Внезапно да. Есть ли на псаче manual memory management -фанбои? А то они вот только что опять соснули.
ulidtko
02.11.2011 01:35 dedicated microblogging account
Recommended by:
@0xd34df00d
Do you really want to delete ?
А теперь сравни с тем, как это сделано в ОСРВ типа QNX :) Где требуется детерменированное время для выделения памяти.
"Про другие алгоритмы управления памятью нам в школе не рассказывали", ну-ну
многабукаф, потом прочитаю.
А вообще, man jemalloc.