Page 1 of 1

Quit a process exe

Posted: Fri May 29, 2020 2:33 pm
by Silvio.Falconi
when I close the main window from the "X" the application is closed, but in reality the exe remains in memory on the computer causing memory leaks.
I can't find the error.

Image


In reality the problem occurs when the Tcalex () class is called: everything is working but if the final user closes the main window the exe remains in memory which is not the case for the other procedures.

the problem does not always manifest itself
there are also moments when if the user closes the window from the "X" it also closes the exe in memory

if tcalex is open in the "Month" view, the exe closes, if instead tcalex is open in the "Daily" or week view
then the exe does not close even if the user returns to the Month view

By chance is there a function or a procedure that goes to check if the exe is still in memory and if it closes it?

I made some checks and I saw there is something no closed on TMonthView or TweekView while on tdayview is ok

Re: Quit a process exe

Posted: Fri May 29, 2020 3:15 pm
by Silvio.Falconi
Now I found a function
it seems to close the exe

HB_GCALL( .t. ) at Begin of Main.prg

then
MemoryFlush() when the exe must be closed

FUNCTION MemoryFlush()
SetProcess( -1, -1, -1 )
RETURN NIL

DLL32 Function SetProcess( hWnd As LONG, nMinWorkingSpace As LONG, nMaxWorkingSpace As LONG ) As LONG PASCAL From "SetProcessWorkingSetSize" Lib "Kernel32.dll"


But I not Know if it run for ever

Re: Quit a process exe

Posted: Sat May 30, 2020 8:56 am
by MOISES
Silvio:

Code: Select all

   PostQuitMessage(0)

   QUIT
 

https://docs.microsoft.com/en-us/window ... uitmessage

Re: Quit a process exe

Posted: Thu Jun 04, 2020 11:00 am
by Silvio.Falconi
I have tried both with:

Code: Select all

PostMessage (0)
quit
i tried with

Code: Select all

HB_GCALL (.t.)
  MemoryFlush ()
always the same remains the "exe" file in memory (in the management of windows activities ) as you can see in this figure

Image


I have a simple window which I then activate with

Code: Select all

   ACTIVATE WINDOW :: oWndMain
       VALID :: ExitFromX ()

 

on exitfromX method there is this

Code: Select all

 if msgYesNo( i18n("¿exit?") )
    
      SetWinCoors( ::oWndMain, ::cIniFile )

       MemoryFlush()
      RETURN .t.
   end

Please Help Me , this happened only with Tcalex class !!!

I don't think anyone who uses tcalex doesn't have this problem

Re: Quit a process exe

Posted: Fri Jun 05, 2020 10:36 am
by Otto
Hello Silvio,
maybe you can check the class. Is your class registerd?
Maybe this from Petzold's book help?
Best regards,
Otto


Image

Image

Re: Quit a process exe

Posted: Fri Jun 05, 2020 5:07 pm
by Silvio.Falconi
Otto wrote:Hello Silvio,
maybe you can check the class. Is your class registerd?
Maybe this from Petzold's book help?
Best regards,
Otto


Dear Otto,
what question you ask me
I use Tcalex class on a Dialog ( style ws_child) and this dialog is on a Window ( no Mdi)

this class is registred ?

do not be a professor with me, it is not necessary to show me books and texts,
the error is in the Tcalex which if inserted in a window does not come out if instead it is inserted in a dialog creates problems