Where is TBuf8 stored for local variables????I am confused
| Tue, 2007-12-04 07:07 | |
|
Hi, I tried the following code---- } X::fn() This code crashed with "User 42 panic" untill I commented both the push and pop operations. From documentation I found that some situations for this panic are:------ MY QUESTIONS |
|






Forum posts: 1242
Maybe the most important question is: Where does your confusion come from?
I would say that memory-wise a TBuf is as harmless as a lowly TInt or TBool: You most probably won't run into any memory leak trouble whatsoever with it.
It is also no question where it is, on the stack or on the heap: It is there where you put it. If you declare one inside a method, it goes onto the stack, but does not need management by cleanup stack. If you declare one as a member variable of an object, you could say "it goes into the heap", but always as part of the object, not on its own, as any TInt would do as well, for example. You will have to care about the *object*, not about any TBuf inside it.
Of course you could allocate a TBuf on the heap yourself, as you could even allocate a TBool on the heap, but I don't know of any situation where this would make sense. But if you were, you would have to use the cleanup stack.
René Brunner
Forum posts: 114
Hi,
Any automatic variable (of any type) goes on to the stack if they are declared inside a method as local variable.
The T-Classes can be orphaned on the stack becuase T-Classes do not own external resources.
No need to push the T-Class to clean up stack .
Chao,
Raghav