Click here to Skip to main content
15,891,248 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to solve memory resource management problems in C++ Pin
元昊 潘3-Nov-18 22:00
元昊 潘3-Nov-18 22:00 
GeneralRe: How to solve memory resource management problems in C++ Pin
Richard MacCutchan3-Nov-18 22:18
mveRichard MacCutchan3-Nov-18 22:18 
GeneralRe: How to solve memory resource management problems in C++ Pin
元昊 潘3-Nov-18 22:30
元昊 潘3-Nov-18 22:30 
GeneralRe: How to solve memory resource management problems in C++ Pin
Richard MacCutchan3-Nov-18 22:34
mveRichard MacCutchan3-Nov-18 22:34 
PraiseRe: How to solve memory resource management problems in C++ Pin
元昊 潘3-Nov-18 23:44
元昊 潘3-Nov-18 23:44 
GeneralRe: How to solve memory resource management problems in C++ Pin
Stefan_Lang13-Nov-18 22:52
Stefan_Lang13-Nov-18 22:52 
GeneralRe: How to solve memory resource management problems in C++ Pin
meerokh7-Nov-18 0:39
meerokh7-Nov-18 0:39 
GeneralRe: How to solve memory resource management problems in C++ Pin
Stefan_Lang13-Nov-18 22:34
Stefan_Lang13-Nov-18 22:34 
I am referring to the added information in your other responses, specifically your goal to implement a memory pool.

First, it seems to me you've set your goal prematurely: You're worrying about the performance overhead of overusing new/delete, but I'm not at all sure that this will really be relevant in your environment.
- For one, your application may be fast enough as it is. Any time spent on optimization is wasted.
- Second, even if it is slow, memory allocation may only eat ~10% of the total processing time. therefore even a 100-fold speedup can not increase your app speed by more than 10%.
- Third, even if the amount of time your app spends on memory management is really excessive, the problem is most likely the programming that requires so much allocations and deallocations, not the speed of each individual allocation. You can very likely improve the speed much more by fixing that programming rather than fixing your memory handling.
- Fourth, the systems memory management functions are already very efficient. Doing a billion allocations and deallocations takes only a few seconds. It's not so easy to beat that without a very thorough understanding of memory management as well as a good understanding of the memory dynamics of your application. And if you do understand what your app needs, you should be able to come up with a program design that doesn't lean so heavily on memory management.

All that said, if you still want a memory manager, why not use what you can already find on the web? For instance here is a neat memory manager that is already implemented as an allocator for using it with STL containers: GitHub - foonathan/memory: STL compatible C++ memory allocator library using a new RawAllocator concept that is similar to an Allocator but easier to use and write.[^] . Being an allocator means you can just use STL containers rather than custom containers and don't need to care about explicitely allocating or deallocating individual elements.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

QuestionShared sections in a DLL Pin
Bram van Kampen2-Nov-18 13:39
Bram van Kampen2-Nov-18 13:39 
AnswerRe: Shared sections in a DLL Pin
Afzaal Ahmad Zeeshan2-Nov-18 13:55
professionalAfzaal Ahmad Zeeshan2-Nov-18 13:55 
AnswerRe: Shared sections in a DLL Pin
11917640 Member 5-Nov-18 4:34
11917640 Member 5-Nov-18 4:34 
QuestionPrint Bitmap from Printing Class Library Pin
Member 1403961931-Oct-18 7:29
Member 1403961931-Oct-18 7:29 
AnswerRe: Print Bitmap from Printing Class Library Pin
Victor Nijegorodov31-Oct-18 8:15
Victor Nijegorodov31-Oct-18 8:15 
GeneralRe: Print Bitmap from Printing Class Library Pin
Member 1403961931-Oct-18 8:31
Member 1403961931-Oct-18 8:31 
GeneralRe: Print Bitmap from Printing Class Library Pin
Victor Nijegorodov31-Oct-18 8:37
Victor Nijegorodov31-Oct-18 8:37 
GeneralRe: Print Bitmap from Printing Class Library Pin
Richard Deeming31-Oct-18 9:14
mveRichard Deeming31-Oct-18 9:14 
GeneralRe: Print Bitmap from Printing Class Library Pin
Victor Nijegorodov31-Oct-18 11:06
Victor Nijegorodov31-Oct-18 11:06 
GeneralRe: Print Bitmap from Printing Class Library Pin
Victor Nijegorodov31-Oct-18 8:43
Victor Nijegorodov31-Oct-18 8:43 
AnswerRe: Print Bitmap from Printing Class Library Pin
leon de boer31-Oct-18 17:27
leon de boer31-Oct-18 17:27 
QuestionReferencing a class in other in a other class Pin
ForNow28-Oct-18 3:43
ForNow28-Oct-18 3:43 
AnswerRe: Referencing a class in other in a other class Pin
Victor Nijegorodov28-Oct-18 7:35
Victor Nijegorodov28-Oct-18 7:35 
GeneralRe: Referencing a class in other in a other class Pin
ForNow28-Oct-18 7:37
ForNow28-Oct-18 7:37 
GeneralRe: Referencing a class in other in a other class Pin
Richard MacCutchan28-Oct-18 11:34
mveRichard MacCutchan28-Oct-18 11:34 
GeneralRe: Referencing a class in other in a other class Pin
Stefan_Lang31-Oct-18 3:59
Stefan_Lang31-Oct-18 3:59 
AnswerRe: Referencing a class in other in a other class Pin
Joe Woodbury28-Oct-18 9:02
professionalJoe Woodbury28-Oct-18 9:02 

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.