ActiveX Memory consumption

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Portwolf
Posts: 161
Joined: 08 Oct 2018, 12:57

ActiveX Memory consumption

09 Feb 2019, 04:34

Hello,

I've got a script that load an ActiveX explorer on a GUI.
That script goes into a website, checks certain elements in the code to see if website is available, logs into a page, and after checking more stuff on the logged in section, it logs out and restarts the process.

Code: Select all

   
   Gui, Add, ActiveX, x460 y23 w540 h415 vWB hwndATLWinHWND, Shell.Explorer
   WB.silent := true
Problem:
Program starts by using ~60MB of ram, and after 24h it's using 1.5GB....
Is there any way to "reset" the ActiveX part of the GUI or clean up the memory used by it?
safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: ActiveX Memory consumption

10 Feb 2019, 05:19

Try to set WB := "" at the end, before repeating your task.
If that doesn't work change that for ObjRelease(WB). (Which actually I'm not sure that is a proper use.)

I had a similar problem a while ago and I don't remember how I solved it but it was one of this 2 ways.
So, I'd be interested to know if the first option fixes the problem without having to rely on the second.
safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: ActiveX Memory consumption

10 Feb 2019, 05:33

... Or was it that I was creating windows and I wasn't using Gui, Name:Destroy for them... ?
Portwolf
Posts: 161
Joined: 08 Oct 2018, 12:57

Re: ActiveX Memory consumption

10 Feb 2019, 06:00

Yes, but in that way, i have to recreate the gui over and over again to reload the WB.
The program is a GUI with the browser in it, and it tests elements of a website.
So, i have to keep the GUI working.

I just want to clean the ActiveX object, if that makes any sense.. Like, restart it, without changing the GUI.
safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: ActiveX Memory consumption

10 Feb 2019, 08:37

I can't help you with that. I've been refreshing the full window to get away from that ActiveX problem.

I was thinking of deleting the control to replace it, but the documentation explicitly states that GuiControl, Delete is not implemented. And suggests to recreate the window.
User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: ActiveX Memory consumption

10 Feb 2019, 10:28

if destroying the gui does solve this, then you can perhaps just put the activeX control in a child window within a parent and just destroy the child.
mast4rwang
Posts: 141
Joined: 19 Jul 2017, 09:59

Re: ActiveX Memory consumption

10 Feb 2019, 10:48

Hellbent wrote:
10 Feb 2019, 10:28
if destroying the gui does solve this, then you can perhaps just put the activeX control in a child window within a parent and just destroy the child.
You monster...
Portwolf
Posts: 161
Joined: 08 Oct 2018, 12:57

Re: ActiveX Memory consumption

12 Feb 2019, 05:50

mast4rwang wrote:
10 Feb 2019, 10:48
Hellbent wrote:
10 Feb 2019, 10:28
if destroying the gui does solve this, then you can perhaps just put the activeX control in a child window within a parent and just destroy the child.
You monster...
:lol: :lol: :lol:

I used to have that, creating the Explorer as a external window, even hidden.
But the visual verification that the process gives on the GUI is also a way of verification, to make sure everything is going ok..
Can i have it on the GUI but as a child process? Is that even possible?
safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: ActiveX Memory consumption

12 Feb 2019, 14:26

There is a DllCall for SetParent....

But it has quite a lot redrawing issues that I've never managed to fix...

I've tried WinSet-redraw, changing ExStyles for parent and child, SendMessage to redraw and probably more things that I don't remember....

I'm talking about:
DllCall("SetParent", "uint", ChildHwnd, "uint", ParentHwnd)

A google search can bring various results.

If you manage to do something I'd be interested to know.


Edit: The DllCall is similar to the gui option +Parent%ParentHwnd%.
safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: ActiveX Memory consumption

12 Feb 2019, 14:44

F******inally!!!

Code: Select all

Gui, A:New, +HwndAId +Resize +0x2000000  ; +WS_CLIPCHILDREN Fixes drawing problems with child.
Gui, A:Add, Text, w600 h400, AAAA
Gui, A:Show

Gui, B:New, +HwndBId  -Caption -Border
Gui, B:Color, Yellow
Gui, B:Add, Text, x0 y0 w400 h200, BBBB
Gui, B:Show, x50 y50

Gui, B:+Parent%AId%
( +0x2000000 , Thanks to this thread.)
Portwolf
Posts: 161
Joined: 08 Oct 2018, 12:57

Re: ActiveX Memory consumption

13 Feb 2019, 07:13

Funny enough, i have drawing problems in my gui by adding that...
So, i am pretty sure it does not apply.

Also, i've partially used your answer, and i have placed the ActiveX on a secondary, child GUI. So, i might get this working after all..
safetycar
Posts: 435
Joined: 12 Aug 2017, 04:27

Re: ActiveX Memory consumption

13 Feb 2019, 09:25

On the last post of the thread I linked above there's a little comment that says:

Code: Select all

NOTE: Microsoft recommends that you always include the WS_VISIBLE, WS_CLIPSIBLINGS, and WS_CLIPCHILDREN styles in the new value. This means the value of nVal would always be at least 0x16000000.
You said you don't need it but in case you wanted to check it.
Portwolf
Posts: 161
Joined: 08 Oct 2018, 12:57

Re: ActiveX Memory consumption

13 Feb 2019, 09:34

Yeah, kinda didn't notice that :lol: :lol:

My bad :oops:
garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: ActiveX Memory consumption

14 Feb 2019, 08:54

I used safetycar's example ( parent / child )
checkmemory

Code: Select all

at begin Listview = ~ 14500 kB-RAM
Activex           = ~ 84000
then Listview     = ~ 29000 

Code: Select all

;- ActiveX works with videolan ( vlc.exe )
;--------------------------------
Gui, 2: +HwndAId  +0x2000000  ; +WS_CLIPCHILDREN Fixes drawing problems with child.
;Gui, 2: +HwndAId +0x16000000
Gui, 2: -DPIScale
Gui, 2:Color,Black,
Gui, 2:Font,s12 cGray,Lucida Console
Gui, 2:Add, Text    ,x10  y10    w500 ,Listview is the parent
Gui, 2:Add,button   ,x10  y40    w300  h40  gA1,ActiveX (Child) 
Gui, 2:Add,button   ,x350 y40    w300  h40  gA2,Listview (Parent)
Gui, 2:Add,Listview ,x50  y100   w1500 h950 cBackgrounGray grid, A|B
Gui, 2:Add,Text     ,x50  y1080  w300      vMemoryX   cYellow         ;- Memory_used
Gui, 2:Show,x100 y100 w1600 h1150
gosub,memorycheck
settimer,memorycheck,1000
return
;--------------------------------
a1:
Gui, 3: +HwndBId  -Caption -Border
Gui, 3: -DPIScale
Gui, 3:Color,Gray,Gray
Gui, 3:Font,s14 cGray,Lucida Console
;Gui, 3:Add, Text,x0  y10 w500 center,This is the Child
id1=yKbzBGntI8Q    ;- Li Xiang Lan - Ye lai xiang
;id1=sraZaL6jylM   ;- Lilian de Celis - El relicario
;id1=l9lw-zQcZ58    ;- Gloria Lasso - Etranger au paradies
F1=https://www.youtube.com/watch?v=%id1%
xxb=VideoLAN.VLCPlugin.2
Gui, 3:Add,ActiveX, x0 y0   w1500  h950 vVlcx,%xxb%
Gui, 3:Show       , x50 y100 w1500  h950
Gui, 3:+Parent%AId%
vlcx.playlist.stop()
vlcx.playlist.items.clear()
sleep,500
vlcx.playlist.add(F1,"","""""")   ;- MEM- 84000-kB
vlcx.playlist.next()
return
;--------------------------------
a2:
vlcx.playlist.stop()
vlcx.playlist.items.clear()
;ObjRelease(vlcx)
vlcx:=""                ;- mem=29000-kB
sleep,500
Gui,3:destroy
return
;--------------------------------
2Guiclose:
exitapp
;-------- https://autohotkey.com/boards/viewtopic.php?f=5&t=43654 ---
memorycheck:
memx:=checkWorkingset()//1024 . "-kB-RAM"
GuiControl,2:Text,MemoryX,%memx%
return
checkWorkingset(pid:=""){
    static wmi:=comObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . a_computerName . "\root\cimv2")
    pid:=pid?pid:dllCall("GetCurrentProcessId")
    processInfo:=wmi.execQuery("select WorkingSetSize,ProcessId from Win32_Process")._NewEnum
    while(processInfo[item]){
        if(item.processId=pid){
            workingSet:=item.WorkingSetSize
            break
        }
    }
    return workingSet
}
;-----------------------------------------------------------------

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jaka1 and 144 guests