[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: FYI, Epoc memory-leak
- From: "Andrew Wheeler" <awheeler@...>
- Date: Wed, 9 May 2001 14:23:33 -0700
> OK, I'll make the distinction between EXEs and APPs instead. But you seem
> be saying I can change my list to:
> 1. C/C++ programs must call CloseSTDLIB() if they do any Lua I/O.
> 2. OPL programmers must call LuaClose:() (and I have to make the OPX
> call CloseSTDLIB()).
Ok, I studied Epoc's STDLIB documentation a bit more and it seems the OS
requires a call to CloseSTDLIB() after any and all calls into the STDLIB
DLL: I think this is the case because "errno" is stored w/in the
thread-local storage structure, _reent. The documentation does also that
that the call is only needed for EIKON .app's, and not for .exe's: we
reasoned this was the case before, but weren't certain it was w/in spec.
Anyway, here's the doc-section, below:
--- From EPOC C/C++ SDK
EIKON has a requirement that all resources which were allocated by an
application must be cleaned up by the time the program terminates. On the
EPOC Emulator, in debug builds, failure to do this will cause a panic from
the __UHEAP_MARKEND macro.
Because the data allocated in the thread-local storage for STDLIB's DLL (the
_reent structure) is not automatically cleaned up when the EIKON environment
is destroyed, it must be cleaned up by the user of STDLIB.
The function to achieve this is CloseSTDLIB(). To use this function, file
\sys\reent.h should be included in the project. Call CloseSTDLIB() after the
point at which it is known that code in STDLIB's DLL will no longer be
called and its thread-local storage no longer needed.
For example, see the destructor for CExampleDocument in
---- End EPOC C/C++ SDK
That being said, I'd leave it to:
1. C/C++ .app's that utilize lua must call CloseSTDLIB() before
application-exit. C/C++ .exe's need not call CloseSTDLIB(). (See "Porting"
page in EPOC's C/C++ SDK online-help for more information).
2. OPL programmers must call LuaClose:().
That way you're not making any assumptions outside the scope of the EPOC
documentation: you're just regurgitating what EPOC is telling you to do.
(Oh, we're making one assumption: OPL sits on top of EIKON).