Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User jpgustaf's Avatar
    Join Date
    Aug 2007
    Location
    Espoo, Finland
    Posts
    19
    Hi!

    I tried the following function with S60 3rd ed. FP1 but it seems like CWlanScanInfo leaks memory the function leaves even if it's added to the cleanup stack.

    Code:
    CWlanScanInfo* scanInfo=CWlanScanInfo::NewL();
    CleanupStack::PushL( scanInfo );
    if ( someThingHappens ) 
       {
       User::Leave( KErrMyOwnError );
       }
    CleanupStack::PopAndDestroy();
    Is there something I have done wrong (some additional steps to add CWlanScanInfo into the cleanup stack)?

  2. #2
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    27,744
    Why do you think that there is a leak?

  3. #3
    Registered User jpgustaf's Avatar
    Join Date
    Aug 2007
    Location
    Espoo, Finland
    Posts
    19
    Thanks for your reply.

    Quote Originally Posted by wizard_hu_ View Post
    Why do you think that there is a leak?
    My application exits with ALLOC: 260200ba, that seems to disappear if CWlanScanInfo is not created.

    The full function looks like this
    Code:
    CDesC8Array* CWlanScanner::AccessPointMacArrayL()
        {
        const TInt KMaxNumberOfAccessPoints( 20 );
        CDesC8Array* accessPoints = 
            new (ELeave) CDesC8ArrayFlat(KMaxNumberOfAccessPoints);
        CleanupStack::PushL( accessPoints );
    
        CWlanScanInfo* scanInfo=CWlanScanInfo::NewL();	
        CleanupStack::PushL( scanInfo );
        CWlanMgmtClient* client=CWlanMgmtClient::NewL(); // <--- This leaves if WLAN is not supported
        CleanupStack::PushL( client );
    
        client->GetScanResults(*scanInfo);	
     
        [...] // Lines to handle scanInfo removed
    
        CleanupStack::PopAndDestroy( client );
        CleanupStack::PopAndDestroy( scanInfo );
        CleanupStack::Pop( accessPoints );
    
        return accessPoints;
        }
    
    // AccessPointMacArrayL function is called inside the trap
    CDesC8Array* wlanArray = NULL;
    TRAPD( err, wlanArray = AccessPointMacArrayL(); )
    
    [..] // Handle error codes
    
    if ( wlanArray ) 
        {
        wlanArray.Reset();
        }
    delete wlanArray;

  4. #4
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    27,744
    Since it probably happens in the emulator, you can check what HookLogger finds. It is downloadable from the Tools section on http://developer.symbian.com

  5. #5
    Registered User neil.young's Avatar
    Join Date
    Nov 2006
    Posts
    568
    Sorry for hijacking and re-animating this rather old thread. I'm appearing a strange problem with a Nokia 6650d-1bh (AT&T brand), which I don't own. It seems, that this sequence doesn't pass. It breaks or crashes (don't know exactly, because I don't have such a box).

    Code:
    #ifndef __WINS__		
    	CWlanScanInfo* scanInfo = CWlanScanInfo::NewL();
    	CleanupStack::PushL(scanInfo);
    	CWlanMgmtClient* client = CWlanMgmtClient::NewL();
    	CleanupStack::PushL(client);
    	client->GetScanResults(*scanInfo);
    	for (scanInfo->First(); !scanInfo->IsDone(); scanInfo->Next())
    		{
    		if (iUploadUrl.Length() < 8192 - 32)
    			{
    			TWlanBssid bta;
    			scanInfo->Bssid(bta);
    			signalStrength = scanInfo->RXLevel();
    // do a bit more processing...
    
    			}
    		}
    	CleanupStack::PopAndDestroy(2);
    #endif
    The box doesn't have WiFi, could this lead to a condx, in which scanInfo is NULL? (the only explanation I have currently).

    Regards

  6. #6
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    27,744
    Personally I would rather expect a KErrNotFound leave code from CWlanScanInfo::NewL, because if you check it (you can, since it is an inline method), it tries to load an ECOM plugin. Which probably does not exist on devices without WLAN support. You can check the Remote Device Access service, and ask for a WLAN-less device. It is accessible via "I Want To", test, etc. direct link: http://www.forum.nokia.com/rda
    In fact this provides the answer to the original question: ECOM has to be uninitialized using REComSession::FinalClose after finishing its usage.

  7. #7
    Registered User neil.young's Avatar
    Join Date
    Nov 2006
    Posts
    568
    Quote Originally Posted by wizard_hu_ View Post
    Personally I would rather expect a KErrNotFound leave code from CWlanScanInfo::NewL, because if you check it (you can, since it is an inline method), it tries to load an ECOM plugin.
    Hi Wizard_hu,

    thanks for your answer. Right now I don't know, how to check for KErrNotFound, could you please be a bit more specific?

    TIA

  8. #8
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    27,744
    NewL follows a Symbian naming convention: L means that this method can Leave. However leaves can be TRAP-d, so you could do something like this:
    Code:
    CWlanScanInfo* scanInfo = NULL;
    TRAPD(err,scanInfo = CWlanScanInfo::NewL());
    if(err==KErrNone)
    {
        your original code here, PushL ... PopAndDestroy
    }
    else
    {
        some error happens, display some message, or just ignore it
    }
    Note that normally I would suggest enabling the panic code: http://wiki.forum.nokia.com/index.ph...ded_panic_code (since you used the 'we do not like word', crashes), just it is not a real option if you do not have access to the device.

  9. #9
    Registered User neil.young's Avatar
    Join Date
    Nov 2006
    Posts
    568
    Yes, thanks. Found it by myself meanwhile.
    Regards

  10. #10
    Registered User neil.young's Avatar
    Join Date
    Nov 2006
    Posts
    568
    Works and is also a means to let the code run in the emulator.
    Regards

Similar Threads

  1. Tracking memory leaks
    By nadav70 in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 4
    Last Post: 2007-12-05, 21:00
  2. getResourceAsStream leaks memory on S60
    By copperdragon in forum Mobile Java General
    Replies: 18
    Last Post: 2005-09-13, 14:56
  3. Memory leaks
    By ManishPatil in forum Symbian C++
    Replies: 0
    Last Post: 2004-12-09, 11:55
  4. Memory Leaks
    By abhishekmishra in forum Symbian C++
    Replies: 1
    Last Post: 2002-08-21, 15:44
  5. can not successfully link any sample using .NET
    By lobotomat in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2002-08-20, 00:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved