Jump to content

Memory Leak?


Arlen
 Share

Recommended Posts

I think I have memory leak issue...

Every time I use _IENavigate() my Memory Ram goes up and never down.. I could reach 1gb just using this function. Which is weird..

#include <IE.au3>
#include <GUIConstantsEx.au3>
#RequireAdmin

Global $oIE = _IECreateEmbedded()
Global $Form1 = GUICreate("Form1", 920, 466, 502, 342)
GUICtrlCreateObj($oIE, 8, 72, 897, 370) ;IE OBJ
Local $Button1 = GUICtrlCreateButton("FETCH", 808, 8, 91, 57)
GUISetState(@SW_SHOW)
While 1
    Local $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Fetch()
    EndSwitch
WEnd

Func Fetch()
For $i = 0 To 20
    _IENavigate($oIE, 'https://www.google.com/search?source=hp&ei=hzprXM_zN-zs_QbExry4CQ&q=sad&btnK=Google+Search&oq=&gs_l=psy-ab.3..35i39j0i67l9.2993.3926..4083...1.0..0.137.749.0j6......0....1..gws-wiz.....6.eVCDaXHQXYA')
Next
EndFunc

 

Edited by Arlen
Link to comment
Share on other sites

Wow that's nasty.  We probably need a way to free the memory stored in $oIE.  I sunk 40 minutes into this, different tests that didn't solve the issue.

Doesn't work:

#include <IE.au3>
#include <GUIConstantsEx.au3>
#RequireAdmin

Global $oIE
Global $Form1
Global $Button1
Global $controlID
$Form1 = GUICreate("Form1", 920, 466, 502, 342)
While 1
    Local $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Fetch("https://www.google.com/search?hl=en&authuser=0&ei=Km5rXPXULY2l_QbE2ICICw&q=tube+snake+boogy&oq=tube+snake+boogy&gs_l=psy-ab.3..0i13l10.59391.60854..61379...1.0..0.159.577.0j5......0....1..gws-wiz.SM0Ug2XoHUM")
    EndSwitch
WEnd

Func Fetch($URL)
    Form1Create()
    _IENavigate($oIE, $URL)
EndFunc

Func Form1Create()
    ;$Form1 = GUICreate("Form1", 920, 466, 502, 342)
    ;If IsObj($oIE) Then $oIE.quit; = 0;$oIE.quit
    $oIE = 0
    GUICtrlDelete($controlID)
    GUICtrlDelete($Button1)
    GUIDelete($Form1)
    $Form1 = GUICreate("Form1", 920, 466, 502, 342)
    $oIE = _IECreateEmbedded()
    $controlID = GUICtrlCreateObj($oIE, 8, 72, 897, 370) ;IE OBJ
    $Button1 = GUICtrlCreateButton("FETCH", 808, 8, 91, 57)
    GUISetState(@SW_SHOW)
EndFunc

 

Because_IECreateEmbedded() doesn't seem to have functions to IE.quit.  You could try using this Example code instead: https://www.autoitscript.com/forum/topic/99234-iecreate2/

 

Edited by Xandy
Link to comment
Share on other sites

20 minutes ago, Xandy said:

Wow that's nasty.  We probably need a way to free the memory stored in $oIE.  I sunk 40 minutes into this, different tests that didn't solve the issue.

Doesn't work:

#include <IE.au3>
#include <GUIConstantsEx.au3>
#RequireAdmin

Global $oIE
Global $Form1
Global $Button1
Global $controlID
$Form1 = GUICreate("Form1", 920, 466, 502, 342)
While 1
    Local $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Fetch("https://www.google.com/search?hl=en&authuser=0&ei=Km5rXPXULY2l_QbE2ICICw&q=tube+snake+boogy&oq=tube+snake+boogy&gs_l=psy-ab.3..0i13l10.59391.60854..61379...1.0..0.159.577.0j5......0....1..gws-wiz.SM0Ug2XoHUM")
    EndSwitch
WEnd

Func Fetch($URL)
    Form1Create()
    _IENavigate($oIE, $URL)
EndFunc

Func Form1Create()
    ;$Form1 = GUICreate("Form1", 920, 466, 502, 342)
    ;If IsObj($oIE) Then $oIE.quit; = 0;$oIE.quit
    $oIE = 0
    GUICtrlDelete($controlID)
    GUICtrlDelete($Button1)
    GUIDelete($Form1)
    $Form1 = GUICreate("Form1", 920, 466, 502, 342)
    $oIE = _IECreateEmbedded()
    $controlID = GUICtrlCreateObj($oIE, 8, 72, 897, 370) ;IE OBJ
    $Button1 = GUICtrlCreateButton("FETCH", 808, 8, 91, 57)
    GUISetState(@SW_SHOW)
EndFunc

 

Because_IECreateEmbedded() doesn't seem to have functions to IE.quit.  You could try using this Example code instead: https://www.autoitscript.com/forum/topic/99234-iecreate2/

 

Your code works for me. But no hope for Microsoft to fix this any time soon..

Link to comment
Share on other sites

I notice that the Memory Leak is caused by the URL?

;This won't leak for me
$URL = 'https://www.google.com/search?hl=en&authuser=0&ei=Km5rXPXULY2l_QbE2ICICw&q=tube+snake+boogy&oq=tube+snake+boogy&gs_l=psy-ab.3..0i13l10.59391.60854..61379...1.0..0.159.577.0j5......0....1..gws-wiz.SM0Ug2XoHUM'

;But this one will always leak
$URL2= 'https://www.google.com/search?source=hp&ei=hzprXM_zN-zs_QbExry4CQ&q=sad&btnK=Google+Search&oq=&gs_l=psy-ab.3..35i39j0i67l9.2993.3926..4083...1.0..0.137.749.0j6......0....1..gws-wiz.....6.eVCDaXHQXYA'

 

Link to comment
Share on other sites

Yes, from what I read, memory leak appears only on certain pages or with certain data.

I was still having a memory leak with my code.  I was only trying to show the methods I had tried using to remove leak.  Nothing worked for me.

I put too much time into it.  I think you should try to use the: iecreate2

Link to comment
Share on other sites

And free the memory before loading a new URL.  But there is no method I know to free the memory with: _IECreateEmbedded().  The help file claimed that deleting the GUI host would free the memory but in my example it does not.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...