RE: [arm-gnu] How do "new" and "delete" work without OS?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [arm-gnu] How do "new" and "delete" work without OS?



Hi Paul,
Thanks for your explanation. Now I am wondering how the malloc and free in the "Newlib" manage memory without OS support. I think there should be very large work amount to implement memory management. Can the malloc and free work efficiently without OS? And is there no any memory leak when using the heap based malloc and free?

Besieds, how can we specify the heap in the linker script file to use malloc and free? And how can I get the  "Newlib"?

Thanks and best regards.
Bill


-----Original Message-----
From: Paul Brook [mailto:paul@xxxxxxxxxxxxxxxx] 
Sent: Thursday, September 16, 2004 8:48 PM
To: arm-gnu@xxxxxxxxxxxxxxxx
Cc: Chen Bill-R63518
Subject: Re: [arm-gnu] How do "new" and "delete" work without OS?


On Thursday 16 September 2004 09:31, Chen Bill-R63518 wrote:
> Dear all,
> I am using arm-none-elf-g++ to compile cpp files. Then I will use 
> arm-none-elf-ld link the objects with libstdc++.a. The output codes 
> will run without any OS. And in the c++ source code some "new" and 
> "delete" operations are called, ie. there are some dynamic memory 
> allocation.
>
> Here are my questions:
> How do the operator "new" and "delete" in the c++ lib work to manage 
> the memory without OS? Should I override the "new" and "delete" 
> operator myself to implement dynamic memory allocation?

The default libstdc++ operator new and delete use the libc malloc and free. Newlib implements a heap based malloc and free using information obtained from 
the program loader/debug monitor. 

To implement different memory management you probably want to modify/replace 
the newlib malloc and free routines.

Paul