Re: How to reduce Zero Initialised region.
- From: Jack Klein <jackklein@xxxxxxxxxxx>
- Date: Wed, 31 Jan 2007 08:52:44 -0600
On 31 Jan 2007 01:50:25 -0800, "Ajai Jose" <ajai.jose@xxxxxxxxx> wrote
in comp.lang.c:
Hi ,
I work on an ARM processor based embedded system. Code is mainly in
C language. The project has a huge source base. We are supposed to
optimise it. Most datastructures are declared as static and which
directly go into the Zero Initialised region. We need to cut the size
of this ZI region by at least 30%.
The one way i see of doing this is by removing these static arrays
and passing a pointer to the data structure whenever required. but
since these global arrays are used through out the code. A re-write
seems inevitable!
two questions I had.
1. Am I right in doing this(passing pointer instead of making the data
structure static) ?
If you pass a pointer to the data structure, the structure itself
still has to exist somewhere. If the values in the structure need to
persist for some time, in between function calls, they probably need
to have static storage duration anyway.
2. Is there any alternative to this ?
Thanks in Advance,
Ajai.
The issue is not so much whether a function accesses a data structure
by a name with external linkage, but rather how long the structure
must exist.
If you have 100 structures and each of them must retain its data from
the time it is initialized for as long as the program runs, then they
pretty much need to have static storage duration.
On the other hand, if your program needs 50 structures when doing one
type of operation, and a different set of 50 structures when doing
another operation, and in both cases does not need the data anymore
once the operation is finished, you can allocate them automatically in
a function or dynamically, and not have them all taking up memory all
the time.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
.
- References:
- How to reduce Zero Initialised region.
- From: Ajai Jose
- How to reduce Zero Initialised region.
- Prev by Date: Does Casting Slow a Program Down?
- Next by Date: Re: Does Casting Slow a Program Down?
- Previous by thread: Re: How to reduce Zero Initialised region.
- Next by thread: Re: How to reduce Zero Initialised region.
- Index(es):
Relevant Pages
|