GetDir() Problem: ALLOC xxxxxxxx

Login to reply to this topic.
Wed, 2005-11-16 12:14
Joined: 2005-11-16
Forum posts: 34
I'm also having a problem with the GetDir() function. I figured somebody here can find out why  I'm having "Memory Leak" ALLOC xxxxxxx error when the function is issued.

Here's the code:

Code:
void CHTMLContainer::SetListData()
    {
    MDesCArray* itemArray = iList->Model()->ItemTextArray();
CDesCArray* itemList = static_cast<CDesCArray*>(itemArray);

TUint a;
TText tItem;

// connect to the file server
RFs fileSession;
CDir* dirList;
TBuf<30> fileName;
TInt stat;

_LIT(KDirName, "C:\\Symbian\\8.0a\\S60_2nd_FP2\\epoc32\\wins\\c\\Nokia\\MyTindahan\\web");
_LIT(KFileSpec,"C:\\Symbian\\8.0a\\S60_2nd_FP2\\epoc32\\wins\\c\\Nokia\\MyTindahan\\web\\*");

// Connect to the file server
stat = fileSession.Connect();

// Get the file list, sorted by name (Leave if an error occurs)
         User::LeaveIfError( fileSession.GetDir(KFileSpec,
KEntryAttMaskSupported,
ESortByName,
dirList));  // [glow=red,2,300]<----- Memory leak error here.[/glow]

// Close the connection with the file server
fileSession.Close();

// Dynamically build list

itemList->Delete(0);

for (TInt a=0; a < dirList->Count(); a++) {
fileName = (*dirList)[a].iName;
itemList->AppendL(fileName);
}

delete dirList;

iList->HandleItemAdditionL(); 
}

Emulator is Series 60 2nd Ed. SDK for Symbian OS, FP 2, Visual C++, WinXP.

Thanks!

Wed, 2005-11-16 18:45
Joined: 2004-07-10
Forum posts: 364
Re: GetDir() Problem: ALLOC xxxxxxxx
How do you know that the memory leak is there?
Where are your heap mark and checking MACROs placed?
Thu, 2005-11-17 01:54
Joined: 2005-11-16
Forum posts: 34
Re: GetDir() Problem: ALLOC xxxxxxxx
hey, mungbeans, thanks for the reply!  Cheezy

I just figured out the error after several (and I mean several) times of doing the old trial-and-error approach (believe me, if all else fail, you'll do the same).

OK the problem is here:

Code:
_LIT(KDirName, "C:\\Symbian\\8.0a\\S60_2nd_FP2\\epoc32\\wins\\c\\Nokia\\MyTindahan\\web");
_LIT(KFileSpec,"C:\\Symbian\\8.0a\\S60_2nd_FP2\\epoc32\\wins\\c\\Nokia\\MyTindahan\\web\\*");

It should be:

Code:
_LIT(KDirName, "C:\\Nokia\\MyTindahan\\web");
_LIT(KFileSpec,"C:\\Nokia\\MyTindahan\\web\\*.html");

I hope this helps some newbies like me out there. Chow!

Thu, 2005-11-17 19:21
Joined: 2004-07-10
Forum posts: 364
Re: GetDir() Problem: ALLOC xxxxxxxx
Hello

How does the path name determine if there is a memory leak or not?
Fri, 2005-11-18 08:48
Joined: 2005-11-16
Forum posts: 34
Re: GetDir() Problem: ALLOC xxxxxxxx
Well from what I understand is that ALLOC errors are caused by memory leaks. But then again, I'm not very much sure if it is.

Anyway, the good thing is that my app is workig now.

Thanks.
Fri, 2005-11-18 11:40
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 2006
Re: GetDir() Problem: ALLOC xxxxxxxx
You should put the file session and the dir list on the cleanup stack.
There will be a leak when GetDir fails or itemList->AppendL leaves.

But for the remaining, I do not see what could be wrong.

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Fri, 2005-11-18 14:32
Joined: 2004-11-29
Forum posts: 1233
Re: GetDir() Problem: ALLOC xxxxxxxx
He got the memory alloc error when calling the function, because his getDir function failed (because of the wrong path)

GetDir failed -> Leave (because of User::LeaveIfError) -> program quits -> Alloc panic because stuff wasn't pushed on cleanupstack.

so the function itself didn't raise an alloc panic.



Tue, 2005-11-29 11:02
Joined: 2005-11-16
Forum posts: 34
Re: GetDir() Problem: ALLOC xxxxxxxx
I agree. Tha exactly what happened.
  • Login to reply to this topic.