Click here to Skip to main content
15,887,746 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: This doesn't seem like much... Pin
honey the codewitch25-Feb-23 22:01
mvahoney the codewitch25-Feb-23 22:01 
GeneralRe: This doesn't seem like much... Pin
jmaida26-Feb-23 9:24
jmaida26-Feb-23 9:24 
QuestionUsing dynamic memory in microcontrollers Pin
CPallini25-Feb-23 5:06
mveCPallini25-Feb-23 5:06 
AnswerRe: Using dynamic memory in microcontrollers Pin
honey the codewitch25-Feb-23 5:15
mvahoney the codewitch25-Feb-23 5:15 
GeneralRe: Using dynamic memory in microcontrollers Pin
CPallini25-Feb-23 5:27
mveCPallini25-Feb-23 5:27 
GeneralRe: Using dynamic memory in microcontrollers Pin
honey the codewitch25-Feb-23 7:29
mvahoney the codewitch25-Feb-23 7:29 
GeneralRe: Using dynamic memory in microcontrollers Pin
CPallini25-Feb-23 7:42
mveCPallini25-Feb-23 7:42 
GeneralRe: Using dynamic memory in microcontrollers Pin
honey the codewitch25-Feb-23 7:54
mvahoney the codewitch25-Feb-23 7:54 
I should have been more clear.

Sure if you do that it would work, but with new there are also other issues. It's not always possible/ideal to use new, such as for example, when you need to allocate an uninitialized array of bytes. It's not a good idea to preinitialize a gob of memory you're going to be overwriting entirely anyway, such as bitmap data. No sense in clearing it if you're just going to fill it with purple as your next step. This gets important on little CPUs.

Also, it's actually easier in practice to tie an allocator to a function pointer and keep things consistent. new can be overloaded inside classes with different behavior. I haven't really thought about the ramifications of that, in terms of a graphics library on IoT, where different memory has different characteristics but it smells to me, as though it would create confusing bugs - allocating from PSRAM in one instance because you call it from somewhere else where it would usually allocate from SRAM.
To err is human. Fortune favors the monsters.

GeneralRe: Using dynamic memory in microcontrollers Pin
jschell28-Feb-23 5:39
jschell28-Feb-23 5:39 
GeneralRe: Using dynamic memory in microcontrollers Pin
CPallini28-Feb-23 10:03
mveCPallini28-Feb-23 10:03 
AnswerRe: Using dynamic memory in microcontrollers Pin
OriginalGriff25-Feb-23 5:52
mveOriginalGriff25-Feb-23 5:52 
GeneralRe: Using dynamic memory in microcontrollers Pin
CPallini25-Feb-23 6:22
mveCPallini25-Feb-23 6:22 
GeneralRe: Using dynamic memory in microcontrollers Pin
honey the codewitch25-Feb-23 22:21
mvahoney the codewitch25-Feb-23 22:21 
AnswerRe: Using dynamic memory in microcontrollers Pin
Ron Anders25-Feb-23 6:07
Ron Anders25-Feb-23 6:07 
GeneralRe: Using dynamic memory in microcontrollers Pin
CPallini25-Feb-23 6:17
mveCPallini25-Feb-23 6:17 
GeneralNo sea too high Pin
RickZeeland25-Feb-23 2:52
mveRickZeeland25-Feb-23 2:52 
GeneralRe: No sea too high Pin
BillWoodruff25-Feb-23 4:45
professionalBillWoodruff25-Feb-23 4:45 
GeneralRe: No sea too high Pin
RickZeeland25-Feb-23 6:46
mveRickZeeland25-Feb-23 6:46 
QuestionRe: No sea too high Pin
Eddy Vluggen25-Feb-23 11:28
professionalEddy Vluggen25-Feb-23 11:28 
AnswerRe: No sea too high Pin
RickZeeland25-Feb-23 18:48
mveRickZeeland25-Feb-23 18:48 
GeneralRe: No sea too high Pin
Eddy Vluggen26-Feb-23 7:23
professionalEddy Vluggen26-Feb-23 7:23 
GeneralRe: No sea too high Pin
Richard Deeming26-Feb-23 22:43
mveRichard Deeming26-Feb-23 22:43 
GeneralRe: No sea too high Pin
RickZeeland26-Feb-23 23:00
mveRickZeeland26-Feb-23 23:00 
RantI hate learning new technologies. Pin
Maximilien25-Feb-23 2:28
Maximilien25-Feb-23 2:28 
GeneralRe: I hate learning new technologies. Pin
Mike Hankey25-Feb-23 2:35
mveMike Hankey25-Feb-23 2:35 

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.