At 06:39 PM 8/12/2004, you wrote:
I have a question about some unexpected C++ behaviour I'm getting.
I have a file with a few functions, compiled into its own segment.
It includes a header file that defines StructA, StructB, and ClassA. ClassA has an array of StructB, which itself has an array of StructA. Straightforward composition.
None of these structs or classes are instantiated in this file. Only their member functions are called. The arrays aren't accessed as they are protected.
However, I find that by varying the size of those arrays, the code size of that segment is affected. Likewise, other segments that include that header file are also affected.
Why is this the case? Is there an explanation? I'm quite curious.
There is only one instance of ClassA, as a member of ClassB which itself has only one instance, created using new (hence in dynamic memory). The program's functions are all members of ClassB, and spread across several segments.
So why would space be allocated for these arrays in each segment? Why is segment size affected by the size of those arrays?
This sounds like an excellent time to right click on the file and choose "disassemble", doing it for the different sizes to see what's different.
The data size can be affected by exception handling or overhead for data used in initializing the arrays.
Thanks, I will definitely try that, although I'm not sure how it will help as I don't know assembly very well.
I don't believe exceptions are enabled.
I just find it strange, because the arrays are in a class which isn't instantiated in this file. So I don't understand why changing the size of that class' member affects the code size. I could understand if it were being instantiated, of course.
But I'll dig deeper. Meanwhile if anyone has ideas let me know.
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
