Saturday, August 02, 2008

Large stack-based descriptors

The amount of stack space on Symbian OS is pretty limited. So you should avoid creating large stack-based descriptors when it is unnecessary to do so. Every symbian developer should be aware of the this and only use stack-based descriptors.

For example, TFileName is typedef-ed as follows:

typedef TBuf TFileName;
where: const TInt KMaxFileName=0x100; // = 256 decimal

Each character in a descriptor is 2 bytes, since Symbian OS is a wide, UNICODE. So each TFileName object created on the stack occupies 512 bytes, it does not matter if it does filled with data or not.

For stack conservation, it's advisable to be aware of the amount of space the following objects consume:

* TFileName 512 bytes
* TEntry 544 bytes
* TFullName 512 bytes
* TName 256 bytes

so it is suggested that you try using little of above descriptor types, or try converting then to heap based descriptors.

further reading

No comments:

stats counter