Symbian
Symbian OS Library

FAQ-0790 How can I close down the system apps on the Nokia 9210 to launch a memory intensive app?

[Index][spacer] [Previous] [Next]



 

Classification: C++ Category: Memory Management & Cleanup
Created: 05/08/2002 Modified: 06/05/2002
Number: FAQ-0790
Platform: Symbian OS v6.0

Question:
My Nokia 9210 app needs as much memory as possible to run satisfactorily. How can I close down the standard system apps to maximise the available RAM?

Answer:
As a user, a useful trick is to start up then close down the Web app which closes down all apps including system apps to maximise the available RAM.

    To do this in code you can use the same approach as the Web app:
    if (!iEikonEnv->QueryWinL(R_CLOSE_ALL_QUERY))
    return;
    iEikonEnv->BusyMsgL(R_BUSY_CLOSING_ALL_TASKS);

    RWsSession ws = iEikonEnv->WsSession();
    TInt count=ws.NumWindowGroups(0);
    if (!count)
    return;
    CArrayFixFlat* handles = new(ELeave) CArrayFixFlat(count);
    CleanupStack::PushL(handles);
    User::LeaveIfError(ws.WindowGroupList(0, handles));
    CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(ws);
    TApaTask task(ws);
    for (TInt i=0; i
    {
    const TInt wgId=(*handles).At(i);
    TRAPD(err, wgName->ConstructFromWgIdL(wgId));
    if(err == KErrNone && !wgName->IsSystem() && !wgName->Hidden()
    && !wgName->IsBusy() && wgName->AppUid()!=MyAppUid)
    {
    task.SetWgId(wgId);
    task.SendSystemEvent(EApaSystemEventShutdown);
    }
    }
    CleanupStack::PopAndDestroy(2); // wgName, handles

      Note that in ROMs other than the original 9210 ROM, this memory management is carried out for you automatically by the system so you do not need to run the above code. You can check if you are running on the older ROM by the method described in FAQ-0789 .

      Also, if you are running this code from a context other than an app context, you can omit "&& wgName->AppUid()!=MyAppUid".