How much is the maxium Tbuf size?

Login to reply to this topic.
Mon, 2008-02-11 13:48
Joined: 2004-12-07
Forum posts: 72

Hello,

I use TBuf freqnently in my app. I hope to know what is the maxium size for TBuf because it is in stack. when should I replace it with HBuf?

Thanks!


Mon, 2008-02-11 14:17
Joined: 2004-11-29
Forum posts: 1232
Re: How much is the maxium Tbuf size?

The maximum theoretical size is about 2 GB.

The maximum practical size is as much stack as you currently have available. (a few KB)

The maximum size you should use is... not big at all...
I would never use a TBuf allocated on stack that is more then maybe 256 bytes.
In fact, I hardly ever use them, would only consider using them if I felt they would help battle heap fragmentation.

Be aware though that the TBuf will only be on stack if you declare it as an automatic variable in a function.
If you put it as a member in a class, it will be allocated wherever your class is (which for C-classes are on the heap if you follow the convention)

I'd recommend you take a look at RBuf instead of both TBuf and HBufC, its a lot more flexible and easy to use then both of them, and always allocate storage for the data in heap.

Mon, 2008-02-11 14:31
Joined: 2007-12-19
Forum posts: 49
Re: How much is the maxium Tbuf size?

@Alh you are wrong, the maximum theoretical descriptor size is about 256 MB. This is because descriptor length is written as TInt32 value but 4 bits of this value defines descriptor type, so descriptor size use remaining 28 bits 2^28 = 268435456B = (about) 256MB

  • Login to reply to this topic.