Click here to Skip to main content
15,849,328 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Embedded and dynamic memory allocation Pin
honey the codewitch15-Nov-23 6:17
mvahoney the codewitch15-Nov-23 6:17 
GeneralRe: Embedded and dynamic memory allocation Pin
Greg Utas15-Nov-23 7:36
professionalGreg Utas15-Nov-23 7:36 
GeneralRe: Embedded and dynamic memory allocation Pin
honey the codewitch15-Nov-23 10:06
mvahoney the codewitch15-Nov-23 10:06 
GeneralRe: Embedded and dynamic memory allocation Pin
trønderen16-Nov-23 2:34
trønderen16-Nov-23 2:34 
GeneralRe: Embedded and dynamic memory allocation Pin
Greg Utas16-Nov-23 3:54
professionalGreg Utas16-Nov-23 3:54 
GeneralRe: Embedded and dynamic memory allocation Pin
trønderen16-Nov-23 6:04
trønderen16-Nov-23 6:04 
GeneralRe: Embedded and dynamic memory allocation Pin
Greg Utas16-Nov-23 9:44
professionalGreg Utas16-Nov-23 9:44 
GeneralRe: Embedded and dynamic memory allocation Pin
trønderen16-Nov-23 11:23
trønderen16-Nov-23 11: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 13:50
professionalGreg Utas16-Nov-23 13:50 
AnswerRe: Embedded and dynamic memory allocation Pin
CPallini15-Nov-23 21:12
mveCPallini15-Nov-23 21:12 
GeneralRe: Embedded and dynamic memory allocation Pin
honey the codewitch16-Nov-23 1:41
mvahoney the codewitch16-Nov-23 1:41 
GeneralRe: Embedded and dynamic memory allocation Pin
CPallini16-Nov-23 1:55
mveCPallini16-Nov-23 1:55 
AnswerRe: Embedded and dynamic memory allocation Pin
leon de boer8-Dec-23 21:59
leon de boer8-Dec-23 21:59 
QuestionC++ reflection Pin
jschell15-Nov-23 4:26
jschell15-Nov-23 4:26 
AnswerRe: C++ reflection Pin
Mircea Neacsu15-Nov-23 4:41
Mircea Neacsu15-Nov-23 4:41 
GeneralRe: C++ reflection Pin
jschell16-Nov-23 5:32
jschell16-Nov-23 5:32 
AnswerRe: C++ reflection Pin
honey the codewitch15-Nov-23 5:35
mvahoney the codewitch15-Nov-23 5:35 
GeneralRe: C++ reflection Pin
jschell16-Nov-23 5:39
jschell16-Nov-23 5:39 
GeneralRe: C++ reflection Pin
honey the codewitch16-Nov-23 6:29
mvahoney the codewitch16-Nov-23 6:29 
GeneralRe: C++ reflection Pin
jschell17-Nov-23 6:32
jschell17-Nov-23 6:32 
GeneralRe: C++ reflection Pin
honey the codewitch17-Nov-23 6:34
mvahoney the codewitch17-Nov-23 6:34 
GeneralRe: C++ reflection Pin
jschell20-Nov-23 8:17
jschell20-Nov-23 8:17 
QuestionHow to "match" multiple occurrences of item in text ? ( Regular expression ) Pin
Salvatore Terress12-Nov-23 7:40
Salvatore Terress12-Nov-23 7:40 
AnswerRe: How to "match" multiple occurrences of item in text ? ( Regular expression ) Pin
Richard MacCutchan12-Nov-23 22:52
mveRichard MacCutchan12-Nov-23 22:52 
QuestionRe: How to "match" multiple occurrences of item in text ? ( Regular expression ) Pin
CPallini13-Nov-23 0:05
mveCPallini13-Nov-23 0: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.