Click here to Skip to main content
15,887,267 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Embedded and dynamic memory allocation Pin
honey the codewitch15-Nov-23 5:17
mvahoney the codewitch15-Nov-23 5:17 
GeneralRe: Embedded and dynamic memory allocation Pin
Greg Utas15-Nov-23 6:36
professionalGreg Utas15-Nov-23 6:36 
GeneralRe: Embedded and dynamic memory allocation Pin
honey the codewitch15-Nov-23 9:06
mvahoney the codewitch15-Nov-23 9:06 
GeneralRe: Embedded and dynamic memory allocation Pin
trønderen16-Nov-23 1:34
trønderen16-Nov-23 1:34 
GeneralRe: Embedded and dynamic memory allocation Pin
Greg Utas16-Nov-23 2:54
professionalGreg Utas16-Nov-23 2:54 
GeneralRe: Embedded and dynamic memory allocation Pin
trønderen16-Nov-23 5:04
trønderen16-Nov-23 5:04 
GeneralRe: Embedded and dynamic memory allocation Pin
Greg Utas16-Nov-23 8:44
professionalGreg Utas16-Nov-23 8:44 
GeneralRe: Embedded and dynamic memory allocation Pin
trønderen16-Nov-23 10:23
trønderen16-Nov-23 10:23 
It all depends on OS/hardware context. "Background" doesn't always mean a background task in the OS sense.

You can offer your applications a heap manager providing allocate/deallocate as intrinsics / inline functions working on freelists with operations synchronized on hardware reservation (available in several architectures), with need for software semaphores. That is all your applications see.

Behind the scenes, your heap manager can have a clock interrupt handler doing the recombination. Even if the clock handler must maintain a list of timed events (it probably has one already!), regular activation of a recombination task is magnitudes cheaper than using OS mechanisms to start a background process in the dotNet sense, or of most other OSes.

Your apps won't know the reason why memory is so tidy all the time. They will get the memory blocks they ask for, in a small handful of instructions; release goes in even less. Your apps are never delayed by any (lengthy?) recombination of buddies. The risk of heap pollution from small memory allocation blocking large recombinations is greatly reduced.

You do not provide details about your procedures: When deallocating, do you search for buddy blocks for recombination of the same size only, or do you recurse to larger blocks, possibly up to the maximum size available? Do you keep freelists sorted for efficient identification of buddies, or are they unsorted?

Corollary: On new allocations, will you allocate new blocks minimizing the pollution of the heap by small blocks preventing allocation of large blocks? This is more or less implicit with sorted freelists, but if your freelists are not sorted, how do you maintain it?
GeneralRe: Embedded and dynamic memory allocation Pin
Greg Utas16-Nov-23 12:50
professionalGreg Utas16-Nov-23 12:50 
AnswerRe: Embedded and dynamic memory allocation Pin
CPallini15-Nov-23 20:12
mveCPallini15-Nov-23 20:12 
GeneralRe: Embedded and dynamic memory allocation Pin
honey the codewitch16-Nov-23 0:41
mvahoney the codewitch16-Nov-23 0:41 
GeneralRe: Embedded and dynamic memory allocation Pin
CPallini16-Nov-23 0:55
mveCPallini16-Nov-23 0:55 
AnswerRe: Embedded and dynamic memory allocation Pin
leon de boer8-Dec-23 20:59
leon de boer8-Dec-23 20:59 
QuestionC++ reflection Pin
jschell15-Nov-23 3:26
jschell15-Nov-23 3:26 
AnswerRe: C++ reflection Pin
Mircea Neacsu15-Nov-23 3:41
Mircea Neacsu15-Nov-23 3:41 
GeneralRe: C++ reflection Pin
jschell16-Nov-23 4:32
jschell16-Nov-23 4:32 
AnswerRe: C++ reflection Pin
honey the codewitch15-Nov-23 4:35
mvahoney the codewitch15-Nov-23 4:35 
GeneralRe: C++ reflection Pin
jschell16-Nov-23 4:39
jschell16-Nov-23 4:39 
GeneralRe: C++ reflection Pin
honey the codewitch16-Nov-23 5:29
mvahoney the codewitch16-Nov-23 5:29 
GeneralRe: C++ reflection Pin
jschell17-Nov-23 5:32
jschell17-Nov-23 5:32 
GeneralRe: C++ reflection Pin
honey the codewitch17-Nov-23 5:34
mvahoney the codewitch17-Nov-23 5:34 
GeneralRe: C++ reflection Pin
jschell20-Nov-23 7:17
jschell20-Nov-23 7:17 
QuestionHow to "match" multiple occurrences of item in text ? ( Regular expression ) Pin
Salvatore Terress12-Nov-23 6:40
Salvatore Terress12-Nov-23 6:40 
AnswerRe: How to "match" multiple occurrences of item in text ? ( Regular expression ) Pin
Richard MacCutchan12-Nov-23 21:52
mveRichard MacCutchan12-Nov-23 21:52 
QuestionRe: How to "match" multiple occurrences of item in text ? ( Regular expression ) Pin
CPallini12-Nov-23 23:05
mveCPallini12-Nov-23 23:05 

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.