If i set the stack size to 10k(0x2800) in the configuration wizard and re-build the code, ZI-data size is 18868. But when i increase the stack size to 20k(0x5000),ZI-data becomes 29108. Why is this so?
Also, since my code never uses dynamic memory allocation, can i set the heap size to 0 bytes?
So subtracting 20k from ZI gives the number of global variables used. Also, via library functions as in the ones written by me or corecm3.h,startup files etc?
So subtracting 20k from ZI gives the number of global variables used.
No. It's not simply the number of variables, it's the space used by those variables (eg, uint8_t takes less space than uint32_t). And it's not just global variables. It can be variables static to a function or a module. And if the variables are initialized, then they might not be stored in the ZI section. They might be stored in the data section.
Also, via library functions as in the ones written by me or corecm3.h,startup files etc?
Yes.
The map file is where you should look if you want an inventory of the memory usage.