[sword-devel] Mem leak in Sword

Troy A. Griffitts sword-devel@crosswire.org
Sat, 14 Dec 2002 13:54:25 -0700


Your test program looks perfectly valid.  I'll have a look at the code.

I added a new interface: SWCacher, that many classes, especially most of 
the drivers, implement now.  It gives standard functions to clear any 
cached data they are holding.  It was originally added out of the need 
for SWORD to have a SMALLER memory consumption for handheld devices, but 
maybe I screwed something up :)  The concept isn't all complete yet. 
Eventually, I'm hoping to have a CacheMgr that we can add any SWCacher 
implementor objects to, and it will take care of flushing the oldest 
accessed caches and be tunable.

I'll keep ya posted on what I find out.

Joachim Ansorg wrote:
> Troy,
> I was working on BibleTime's parallel display of more than one lexicon, which 
> displays only the keys which are in all selected modules.
> Please have a look at the following test program, to go though WebstersDict it 
> uses almost 400MB of Ram. I think it's a mem leak.
> Am I doing something wrong or is it really a bug in Sword?
> I'm not sure if it only happens with WebstersDict.
> Joachim
> ------------------------------------------------------------------------
> #include <swmgr.h>
> #include <swmodule.h>
> #include <iostream.h>
> using namespace std;
> using namespace sword;
> int main (int argc, char* argv[]) {
> 	SWMgr mgr;
> 	SWModule* mod = mgr.Modules["WebstersDict"];	
> 	(*mod) = TOP; //first entry
> 	do {
> 		cout << mod->KeyText() << endl;
> 		(*mod)++;
> 	} while ( !mod->Error() );
> 	(*mod) = TOP; //back to first entry
> };