Monday, May 09, 2005
Tip 3: Need a small known length descriptor? Use TBuf or TBufC.
Larger stack buffers are not recommended. You should limit the size of stack based buffers by putting larger sized descriptor data on the heap using HBufC objects - or by making your larger TBuf objects member variables of C classes, which are always created on the heap. This is because stack space per process is limited on Symbian OS devices, typically to 8 or 12 KB. So if you use significantly larger buffers on the stack, you risk running out of space.
The Windows emulator will actually extend the program stack, so you may not realize there’s a problem until you deploy your code on an actual phone. How will you realize? Well, attempts to use the stack will result in access to memory which is not mapped into the address space of the process the code is running in. An access violation occurs, which generates an exception and a KERN-EXEC 3 panic. Which is fatal.