SV: [Icc-avr] Freeing static variables
Bengt Ragnemalm
benra at imt.liu.se
Mon Oct 22 02:38:53 PDT 2007
The purpose is just to use less RAM. My problem is that I must run this
during the normal execution of the full program and not just prior starting.
I can see several solutions to this but none that I can call well written
code.
Would malloc even work in ICCAVR? I have no idea how it works but I am aware
of the function.
/Bengt
> -----Ursprungligt meddelande-----
> Från: icc-avr-bounces at imagecraft.com [mailto:icc-avr-
> bounces at imagecraft.com] För David Brown
> Skickat: den 22 oktober 2007 11:27
> Till: Discussion list for ICCAVR and ICCtiny Users. You do NOT need
> tosubscribe to icc-announce if you are a member of this.
> Ämne: Re: [Icc-avr] Freeing static variables
>
>
> By their very definition, "static" variables are allocated a fixed
> address in memory by the linker, and cannot be "freed". You have to
> figure out why you might want to re-use the space they take - if you are
> using heap-allocated dynamic memory (a terrible idea on most embedded
> systems!), for example, then you could use malloc and free for the
> calibration data. If you need it for other specific purposes after
> calibration, you could do something like define a union containing a
> calibration data structure and a run-time data structure, as long as you
> are careful to track which one is valid.
>
> mvh.,
>
> David
>
>
> Bengt Ragnemalm wrote:
> > Is there any intelligent way to release the memory used by a static
> > variable?
> >
> >
> >
> > I have a calibration routine that is run the first loops of the program.
> > If the calibration was done in a separate function , I could just use
> > temporary variables but as this is run in the entire normal program loop
> > I can not see any other way than to use statics for my temporary
> > variables in the calibration routine.
> >
> >
> >
> > But after the calibrating is done, it would have been nice to free the
> > space used by the static variables.
> >
> >
> >
> > Maybe there is some better way to do this so any suggestions are
> welcome.
> >
> >
> >
> > Regards,
> >
> > Bengt
> >
>
>
> _______________________________________________
> Icc-avr mailing list
> Icc-avr at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-avr
More information about the Icc-avr
mailing list