×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    40

    Resources not released

    hi,

    I am running an exe from App UI, i kill that exe form ui, but when I kill that exe I want to release some resources from exe which is not happening.
    Following is my code

    Code:
    
    // Global variables
    
    RLibrary lib;
    void *pSymbWrap = NULL;
    
    //  Local Functions
    
    LOCAL_C void MainL()
        {
        //
        // add your program code here, example code below
        //
    
    	
    	TInt iError = KErrNone;
    	TBool boRetVal = EFalse;
    	
    	_LIT(KFUNCNAME, "MainL()");
    	_LIT(KSTART, "Start");
    	_LIT(KEND, "End");
    	
    	 _LIT(KDLL, "swrapcln.dll");
    	
    	#if DEBUG_MAINL
    	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KSTART);
    	#endif
    	
    	User::LeaveIfError(lib.Load(KDLL));
    
    	
    	TLibraryFunction fun1 = lib.Lookup(1);
    	SMBINITL SmbInitL = (SMBINITL)fun1;
    	
    	boRetVal = SmbInitL(&pSymbWrap);
    	if (EFalse == boRetVal)
    	{
    		#if DEBUG_MAINL 
    		_LIT(KMSG, "SmbInitL  failed");
    		WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KMSG);
    		#endif
    		
    	    lib.Close();
    	    return;
    	}
    	
    	if (NULL == pSymbWrap)
    	{
    		#if DEBUG_MAINL 
    		_LIT(KMSG, "pSymbWrap NULL");
    		WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KMSG);
    		#endif
    		
    		return;
    	}
    	
    	//
    	//	Connect to PC
    	//
    	TLibraryFunction fun2 = lib.Lookup(2);
    	SMBCONNECTL SmbConnectL = (SMBCONNECTL)fun2;
    	
    	boRetVal = SmbConnectL(pSymbWrap, KUid, iError);
    	if (EFalse == boRetVal)
    	{	    
    		#if DEBUG_MAINL 
    		_LIT(KMSG, "SmbConnectL fails");
    		WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KMSG);
    		#endif
    		
    	    lib.Close();
    	    return;
    	}
    		
    	#if DEBUG_MAINL
    	_LIT(KMSG, "Connect completes");
    	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KMSG);
    	#endif
    	
    	
    	//	RSemaphore semaphore;
    	 
    	// 	iError = semaphore.OpenGlobal(_L("GLOBAL"), EOwnerProcess);
    	// 	if (iError != KErrNone)
    	// 	{
    	// 		    return;
    	// 	}
    	// 
    	//	semaphore.Signal();
    	//	semaphore.Close();
    	
    	#if DEBUG_MAINL
    	_LIT(KMSGRECV, "Receives start");
    	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KMSGRECV);
    	#endif
    	
    	
    	//
    	//	Receive form PC
    	//  
    	TLibraryFunction fun3 = lib.Lookup(4);
    	SMBRECEIVEL SmbReceiveL = (SMBRECEIVEL)fun3;
    	
    	boRetVal =  SmbReceiveL(pSymbWrap, iError);
    	if (EFalse == boRetVal)
    	{	   
    		#if DEBUG_MAINL 
    		_LIT(KMSGRECVFUN, "SmbReceiveL fails");
    		WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KMSGRECVFUN);
    		#endif
    	
    	    lib.Close();
    	    return;
    	}
    	
    	#if DEBUG_MAINL
    	_LIT(KMSGRECVCOM, "receive completes");
    	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KMSGRECVCOM);
    	#endif
    	
    	   
    	lib.Close();
    	
    	#if DEBUG_MAINL
    	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KEND);
    	#endif
    	
        }
    
    
    LOCAL_C void DoStartL()
        {
        	
        _LIT(KFUNCNAME, "DoStartL()");
    	_LIT(KSTART, "Start");
    	_LIT(KEND, "End");
    	
        #if DEBUG_DOSTARTL
    	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KSTART);
    	#endif
    	
        // Create active scheduler (to run active objects)
        CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
        CleanupStack::PushL(scheduler);
        CActiveScheduler::Install(scheduler);
    
        MainL();
    
        // Delete active scheduler
        CleanupStack::PopAndDestroy(scheduler);
         
        #if DEBUG_DOSTARTL
    	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KEND);
    	#endif
    	
        }
    
    
    //  Global Functions
    
    GLDEF_C TInt E32Main()
        {
        // Create cleanup stack
        __UHEAP_MARK;
       	TInt iError = KErrNone;
    	TBool boRetVal = EFalse;
        CTrapCleanup* cleanup = CTrapCleanup::New();
        
        _LIT(KFUNCNAME, "E32Main()");
    	_LIT(KSTART, "Start");
    	_LIT(KEND, "End");
        
        
        #if DEBUG_E32MAIN
    	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KSTART);
    	#endif
    
        // Run application code inside TRAP harness, wait keypress when terminated
        TRAPD(mainError, DoStartL());
        
        //
        //	Receive form PC
        //  
    	TLibraryFunction fun3 = lib.Lookup(3);
    	SMBDISCONNECTL SmbDisconnectL = (SMBDISCONNECTL)fun3;
    	
    	boRetVal =  SmbDisconnectL(pSymbWrap, iError);
    	if (EFalse == boRetVal)
    	{	   
    		#if DEBUG_E32MAIN 
    		_LIT(KMSGRECVFUN, "SmbReceiveL fails");
    		WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KMSGRECVFUN);
    		#endif
    	
    	    lib.Close();
    	    return;
    	}
        
    	lib.Close();
    	 
        delete cleanup;
        __UHEAP_MARKEND;
        
        #if DEBUG_E32MAIN
    	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KEND);
    	#endif
    	
        return KErrNone;
        }
    Following is log generated of exe
    qhscan.exe E32Main() Start
    qhscan.exe DoStartL() Start
    qhscan.exe MainL() Start
    qhscan.exe MainL() Connect completes
    qhscan.exe MainL() Receives start
    As you can see in above log "qhscan.exe E32Main() End" this has log has not generated.
    At the end of E32Main() i have called SmbDisconnectL of library in which I have relesed the resources which I have used inb library.
    But when I kill process, the process does not come to end of E32Main() function.
    Why is this happeneing?
    Can anybody could suggest solution for where i should release resources

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Resources not released

    Try not Killing the exe, but you should make IPC which with you could tell the exe to exit & free its resources.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    40

    Re: Resources not released

    I have never tried IPC can you give some examples on it or some other solution

  4. #4
    Nokia Developer Champion
    Join Date
    Jan 2008
    Location
    Moscow, Russia
    Posts
    3,348

    Re: Resources not released

    You can find some examples at <path_to_SDK>\Examples\Base\IPC\

  5. #5
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: Resources not released

    Also Wiki has good stuff on the topic, and you could also check Client-Server examples.

Similar Threads

  1. Carbide.vs 3.0 (supporting VS 2005) released!
    By mitts in forum Symbian Tools & SDKs
    Replies: 44
    Last Post: 2010-07-18, 09:30
  2. window server resources
    By everest in forum Symbian
    Replies: 5
    Last Post: 2007-02-25, 19:48
  3. Freeing resources in threads
    By ghauber in forum Symbian
    Replies: 2
    Last Post: 2006-09-06, 12:22
  4. PANIC CONE 8 --> What resources?
    By lazmous in forum Symbian
    Replies: 2
    Last Post: 2004-12-23, 12:28
  5. Replies: 7
    Last Post: 2003-06-27, 15:32

Posting Permissions

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