Click here to Skip to main content
15,914,500 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Save web page Pin
CPallini22-Sep-10 23:00
mveCPallini22-Sep-10 23:00 
QuestionCombining all files in single file Pin
learningvisualc19-Sep-10 22:31
learningvisualc19-Sep-10 22:31 
AnswerRe: Combining all files in single file Pin
«_Superman_»19-Sep-10 22:54
professional«_Superman_»19-Sep-10 22:54 
AnswerRe: Combining all files in single file Pin
Aescleal20-Sep-10 0:33
Aescleal20-Sep-10 0:33 
QuestionSending email with attachment problem Pin
AnayKulkarni19-Sep-10 19:33
AnayKulkarni19-Sep-10 19:33 
QuestionRe: Sending email with attachment problem Pin
David Crow20-Sep-10 5:37
David Crow20-Sep-10 5:37 
QuestionHow to make the Memory Pool thread safe ? [modified][solved] Pin
yu-jian19-Sep-10 17:50
yu-jian19-Sep-10 17:50 
AnswerRe: How to make the Memory Pool thread safe ? [modified] Pin
Aescleal20-Sep-10 0:07
Aescleal20-Sep-10 0:07 
A memory pool (implemented as a custom allocator or overiding new/delete for a class) can improve speed a lot. HOWEVER before you do make sure that your app is actually eating up loads of execution time in the ordinary allocator before doing anything about it. I've seen plenty of people mess about and spend ages optimising allocators and get nothing concrete out of it.

If you decide to use a custom allocator then you make it thread safe the way you do any other object - use a synchronisation object and lock it when doing any operations on the object. Incidentally I've seen the cost of synchronisation wipe out any benefit a custom allocator gives you, so again make sure you're just not replacing a runtime library bottleneck with a carefully crafted homemade one.

There are ways you can reduce locking bottlenecks from an allocator but you start needing to use multiple arenas to allocate from and switch between them on each allocation. This can then start messing up locality of reference (unless you manage interleaved arenas) and again slow everything down again.

Anyway, the point I'm really making here is measure how long your app spends in the allocator. If it's taking an appreciable length of time consider using a third party custom allocator or implementation of new and delete and only write your own if it's still not fast enough.

Another idea would be to use a garbage collector - if you google "Hans" "Boehm" and "garbage collection" you can find a decent one (if you like that sort of thing) that's written by one of the luminaries of the C++ standards committee. Garbage collection has the advantage that when you delete objects the memory is not immediately freed and is recovered in one fell swoop later by the garbage collector reducing contention for the allocator when releasing objects.

Cheers,

Ash

modified on Monday, September 20, 2010 7:05 AM

GeneralRe: How to make the Memory Pool thread safe ? Pin
Maximilien20-Sep-10 1:28
Maximilien20-Sep-10 1:28 
GeneralRe: How to make the Memory Pool thread safe ? Pin
Aescleal20-Sep-10 6:02
Aescleal20-Sep-10 6:02 
AnswerRe: How to make the Memory Pool thread safe ? [modified][solved] Pin
basementman23-Sep-10 4:37
basementman23-Sep-10 4:37 
AnswerRe: How to make the Memory Pool thread safe ? [modified][solved] Pin
Blake Miller28-Sep-10 11:24
Blake Miller28-Sep-10 11:24 
QuestionWhat is the different between Synchronization and block? Pin
yu-jian19-Sep-10 17:45
yu-jian19-Sep-10 17:45 
AnswerRe: What is the different between Synchronization and block? Pin
Moak20-Sep-10 0:36
Moak20-Sep-10 0:36 
GeneralRe: What is the different between Synchronization and block? Pin
yu-jian22-Sep-10 5:07
yu-jian22-Sep-10 5:07 
QuestionHow to change color in vs2008 feature pack? Pin
hanlei000000000919-Sep-10 15:40
hanlei000000000919-Sep-10 15:40 
QuestionAutoComplete with CListCtrl ? Pin
mesajflaviu19-Sep-10 8:22
mesajflaviu19-Sep-10 8:22 
AnswerRe: AutoComplete with CListCtrl ? Pin
«_Superman_»19-Sep-10 20:52
professional«_Superman_»19-Sep-10 20:52 
GeneralRe: AutoComplete with CListCtrl ? Pin
mesajflaviu20-Sep-10 7:13
mesajflaviu20-Sep-10 7:13 
QuestionGetting window name in different language. Pin
gateway2319-Sep-10 2:20
gateway2319-Sep-10 2:20 
AnswerRe: Getting window name in different language. Pin
AmbiguousName19-Sep-10 4:13
AmbiguousName19-Sep-10 4:13 
AnswerRe: Getting window name in different language. Pin
Luc Pattyn19-Sep-10 5:07
sitebuilderLuc Pattyn19-Sep-10 5:07 
GeneralRe: Getting window name in different language. Pin
CPallini19-Sep-10 6:10
mveCPallini19-Sep-10 6:10 
GeneralRe: Getting window name in different language. Pin
Luc Pattyn19-Sep-10 6:16
sitebuilderLuc Pattyn19-Sep-10 6:16 
GeneralRe: Getting window name in different language. Pin
CPallini19-Sep-10 6:25
mveCPallini19-Sep-10 6:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.