×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    2

    Post [Symbian S60 3rd]Memory Full Error while Retrieving the Network Information

    I'm writing a java LBS application which need the cell network information of the phone, as j2ME don't have APIs to get the cell related information. I need a Symbian C++ app to retrieve the network information and provide to java via socket.

    I found a good example at Nokia Site http://wiki.forum.nokia.com/index.ph...-Synchronously to retrieve the network Information.

    The sample works, but i encounter two problems.

    1.Memory Leak.
    TBuf<160> getNetworkInfo(){
    TUint CellId;
    TBuf<30> NetworkId;
    TBuf<30> CountryId;
    TBuf<30> OperatorLongName;
    CNetworkApp::GetNetworkParameters(
    CellId, NetworkId, CountryId, OperatorLongName );

    TBuf<160> iDisplayString;
    iDisplayString.Format(
    _L( "CellId-%d\nNetworkID-%S\nCountryID-%S\nNETWORK-%S" ),
    CellId, &NetworkId, &CountryId, &OperatorLongName );
    return iDisplayString;
    }
    After i continuously call this method around 200 times, i got the error "Memory Full"

    2. Sometime i get the cell id value of "0" when my phone working on dual mode(N80).
    If i use the GSM mode, every time i can get the correct network info.
    But if i change to use dual mode, sometimes the CELL ID could be "0" but rest of info(network id and country id) is correct.

    Anybody have ideals on above issues?

    Thanks a lot!
    cn.caowei@gmail.com

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Bangalore,India
    Posts
    2,146

    Re: [Symbian S60 3rd]Memory Full Error while Retrieving the Network Information

    Well..memory full is essentially a heap overrun issue..so the thing to make sure is that r u getting the memory issue only becuase of this function or otherwise..coz i dont see much wrong with this function per se..

    cheers
    mayank

  3. #3
    Super Contributor
    Join Date
    Jun 2004
    Location
    SymbianLand
    Posts
    763

    Re: [Symbian S60 3rd]Memory Full Error while Retrieving the Network Information

    Quote Originally Posted by cn.caowei@gmail.com View Post
    I'm writing a java LBS application which need the cell network information of the phone, as j2ME don't have APIs to get the cell related information. I need a Symbian C++ app to retrieve the network information and provide to java via socket.

    I found a good example at Nokia Site http://wiki.forum.nokia.com/index.ph...-Synchronously to retrieve the network Information.

    The sample works, but i encounter two problems.

    1.Memory Leak.


    After i continuously call this method around 200 times, i got the error "Memory Full"

    2. Sometime i get the cell id value of "0" when my phone working on dual mode(N80).
    If i use the GSM mode, every time i can get the correct network info.
    But if i change to use dual mode, sometimes the CELL ID could be "0" but rest of info(network id and country id) is correct.

    Anybody have ideals on above issues?

    Thanks a lot!
    cn.caowei@gmail.com
    I think there is a big memory leak in the code of CNetworkApp(If am wrong do correct me).
    I would recommend adding the destructor for CNetworkApp and delete all it's member variables,something like this:
    Code:
    CNetworkApp::~CNetworkApp()
    {
       if(iTelephony)
       {
         iTelephony->Cancel();
        delete iTelephony;
        iTelephony = NULL;
       }
    }
    The second issue am not aware what is the reason.
    --Mayur.

  4. #4
    Super Contributor
    Join Date
    Jun 2004
    Location
    SymbianLand
    Posts
    763

    Re: [Symbian S60 3rd]Memory Full Error while Retrieving the Network Information

    Damn mayank,you beat me at it .
    Ohh actually you didn't.
    --Mayur.

  5. #5
    Registered User
    Join Date
    Aug 2007
    Posts
    2

    Re: [Symbian S60 3rd]Memory Full Error while Retrieving the Network Information

    Hi Mayur

    Very thank for taking time to read the code, your suggestion really helps.
    After i add a de-constructor, i didn't encounter the memory full issue anymore.

    BTW, you mentioned that we should clean all the member variables in the de-constructor,do i need to to clean
    those variables
    CTelephony::TNetworkInfoV1 iNetworkInfoV1;
    TUint& iCellID;
    TDes& iNetworkID;
    TDes& iCountryCODE;
    TDes& iLongNAME;
    As i'm not familiar with C++(i'm leaning Symbian C++ for less than one week), i only know the objects create using
    new keyword need to be delete explicitly.Does it means i don't need to clean above variables?
    If above variable need to be clean as well, how to clean?
    I tried using "delete iNetworkInfoV1" or "iNetworkInfoV1 = NULL", but i got complier error.

    For the CELL ID issue, i suspect this is API bug, because only CELL ID could be wrong and this happens only when i using 3G network(GSM network is ok).
    As a interim solution, i write a loop, if i got the cell id equals "0" i invoke the GetNetworkParameters again until i got the correct cell id.

    Appreciate if anyone can give suggestion on cell id issue.

    Thanks
    cn.caowei@gmail.com

  6. #6
    Super Contributor
    Join Date
    Jun 2004
    Location
    SymbianLand
    Posts
    763

    Re: [Symbian S60 3rd]Memory Full Error while Retrieving the Network Information

    Quote Originally Posted by cn.caowei@gmail.com View Post
    Hi Mayur

    Very thank for taking time to read the code, your suggestion really helps.
    After i add a de-constructor, i didn't encounter the memory full issue anymore.

    BTW, you mentioned that we should clean all the member variables in the de-constructor,do i need to to clean
    those variables

    As i'm not familiar with C++(i'm leaning Symbian C++ for less than one week), i only know the objects create using
    new keyword need to be delete explicitly.Does it means i don't need to clean above variables?
    If above variable need to be clean as well, how to clean?
    I tried using "delete iNetworkInfoV1" or "iNetworkInfoV1 = NULL", but i got complier error.

    For the CELL ID issue, i suspect this is API bug, because only CELL ID could be wrong and this happens only when i using 3G network(GSM network is ok).
    As a interim solution, i write a loop, if i got the cell id equals "0" i invoke the GetNetworkParameters again until i got the correct cell id.

    Appreciate if anyone can give suggestion on cell id issue.

    Thanks
    cn.caowei@gmail.com
    No you don't need to delete any 'T' classes.
    The necessary d'tor code was put in my last post,that't it,nothing more required.
    --Mayur.

  7. #7
    Registered User
    Join Date
    Aug 2008
    Posts
    14

    Unhappy Re: [Symbian S60 3rd]Memory Full Error while Retrieving the Network Information

    Quote Originally Posted by mayur_24 View Post
    I think there is a big memory leak in the code of CNetworkApp(If am wrong do correct me).
    I would recommend adding the destructor for CNetworkApp and delete all it's member variables,something like this:
    Code:
    CNetworkApp::~CNetworkApp()
    {
       if(iTelephony)
       {
         iTelephony->Cancel();
        delete iTelephony;
        iTelephony = NULL;
       }
    }
    The second issue am not aware what is the reason.
    --Mayur.


    the above destructor gives me error as
    error: 'class CTelephony' has no member named 'Cancel' NetworkApp.cpp lbsg/src line 56


    please help

  8. #8
    Super Contributor
    Join Date
    Jun 2004
    Location
    SymbianLand
    Posts
    763

    Re: [Symbian S60 3rd]Memory Full Error while Retrieving the Network Information

    Quote Originally Posted by abhayagp View Post
    the above destructor gives me error as
    error: 'class CTelephony' has no member named 'Cancel' NetworkApp.cpp lbsg/src line 56


    please help
    Sorry buddy it was my bad.
    The code
    Code:
     iTelephony->Cancel();
    should be just replaced with:

    Code:
     Cancel();
    Extremely sorry for the wrong code.
    Will fix it.
    -Mayur.

Similar Threads

  1. Prototype SDK 2.0 setup problem
    By jackmcardle in forum Mobile Java Tools & SDKs
    Replies: 4
    Last Post: 2007-01-09, 16:21
  2. S60 2nd Ed. FP2 wins udeb - No network connection
    By timomon in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2006-12-03, 16:08
  3. Can't get network information...!!!
    By patrickfrei in forum Symbian
    Replies: 2
    Last Post: 2006-11-28, 09:36
  4. How to see network traficc in s60 2nd. Ed. FP3 emulator
    By adamis22 in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2006-08-02, 09:23
  5. confused on s60 2nd edition fp3 emulator network configuration
    By cstommijx in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2006-07-01, 05:43

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×