Re: How to reduce Zero Initialised region.
- From: Eric Sosman <esosman@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Jan 2007 08:28:16 -0500
Ajai Jose wrote:
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) ?
Yes. Or maybe No. We don't know enough about the
constraints and circumstances of your situation to be able
to say with certainty.
2. Is there any alternative to this ?
You might consider a sort of intermediate strategy: Make
the pointer(s) global and static, and initialize them to
point to dynamically-zeroed memory when the program starts.
That is, if the program as it stands now has
int BigArray[LARGE]; /* static and zeroed */
you might change it to
int *BigArray; /* only the pointer is static */
...
void initialize(void) {
BigArray = calloc(LARGE, sizeof *BigArray);
if (BigArray == NULL)
die_horribly();
}
.... and arrange to call initialize() before BigArray is needed
elsewhere in the code.
--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxx
.
- References:
- How to reduce Zero Initialised region.
- From: Ajai Jose
- How to reduce Zero Initialised region.
- Prev by Date: Re: myfree(p)
- Next by Date: Re: inside scanf [trap rep]
- Previous by thread: Re: How to reduce Zero Initialised region.
- Next by thread: Re: How to reduce Zero Initialised region.
- Index(es):
Relevant Pages
|