This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: Question about empty C++delete functions
- From: Andrew Lunn <andrew dot lunn at ascom dot ch>
- To: Joris Roussel <joris dot roussel at inventel dot fr>
- Cc: ecos-discuss at sources dot redhat dot com
- Date: Sun, 1 Sep 2002 14:26:01 +0200
- Subject: Re: [ECOS] Question about empty C++delete functions
- References: <5.1.0.14.0.20020830172355.00a790c8@172.16.1.2>
On Fri, Aug 30, 2002 at 06:43:19PM +0200, Joris Roussel wrote:
> Dear all,
>
> I have a question about the "Provide empty C++ delete functions"
> (CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS) option of eCos configuration.
>
> If I keep it to its default value (enabled state), the memory allocated
> after a class object new is never freed when the class object is deleted.
>
> So, newing and deleting several objects will fill the target memory and
> finally bring to a target crash.
>
> As I haven't really understood the explanation given in the Configuration
> Tool, could someone tell me more about this option utility ?
In embedded systems, you generally don't do dynamic memory stuff. You
allocate all your memory once at startup and never free it. If the
system gets past startup, you know you will not run out of
memory. Thus delete is not needed in most systems. Providing an empty
delete function just saves on code space.
If you are doing dynamic memory stuff, you will want delete so disable
this option and be prepared for new to fail at any point in time and
know how to recover from it.
Andrew
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss