Jump to content

--> memory leak or process crossover ?


Recommended Posts

hello all,

i would normally do my own homework till i die but this one seems somewhat incongruous.

the attached file is quite simple but:

if i compile this script and execute two or three runs on the same compiled executable,

the variable $datapoint crosses over from one executable to the other.

there is definitely something simple that i just cannot see here.

it is so integral but i just do not see how one process corrupts data from one process to the other.

Sharing...

-Garry

and thank you.

gogo autoit!

Link to comment
Share on other sites

hello all,

i would normally do my own homework till i die but this one seems somewhat incongruous.

the attached file is quite simple but:

if i compile this script and execute two or three runs on the same compiled executable,

the variable $datapoint crosses over from one executable to the other.

there is definitely something simple that i just cannot see here.

it is so integral but i just do not see how one process corrupts data from one process to the other.

Sharing...

-Garry

and thank you.

gogo autoit!

You seemed to have forgotten the file :)

Link to comment
Share on other sites

first posting,

and i did attach the file,

but whatever...

thank you for letting me know.

the folllowing is the code:

#include <IE.au3>
#include <Array.au3>
#include <File.au3>
#include <Timers.au3>
#include <Date.au3>
;----------------------------------------------------------------------------------------------------------
;                   get and set stock choice
;
Local $inst = InputBox("instance number", "", "1", "",100, 20, @DesktopWidth-200,@DesktopHeight-200)
Local $var = InputBox("", "","SRCE","",100, 20, @DesktopWidth-200,@DesktopHeight-200)
local $sURL = "[url="http://www.google.com/finance?q"]http://www.google.com/finance?q[/url]=" & $var
Local $oIE = _IECreate($sURL,0,1,1,1);<-visible
Local $handle = WinGetHandle($oIE)
WinSetState($handle, "",@SW_MAXIMIZE)
$go2 =0
Do
   _IEAction($oIE, "refresh")
   _IELoadWait($oIE)
   Local $oTable1 = _IETableGetCollection ($oIE,1); table 2 is where the price is om coloumn 1
   Local $aTableData1 = _IETableWriteToArray ($oTable1, True)
   ;_ArrayDisplay($aTableData1)
   Local $datapoint = $aTableData1[0][1]
   if MsgBox(4,"is this the price?", $datapoint) = 6 then $go2=1
Until $go2
Local $quantitystocks = InputBox("", "",round(1000/$datapoint,0),"",100, 20, @DesktopWidth-200,@DesktopHeight-200)
;----------------------------------------------------------------------------------------------------------
;                    set variables
local $period = 20
Local $go = 1
Local $buypoint = $datapoint
Local $momentgain=0
Local $belowbuyout=0
Local $gammaout=1000
Local $ratchet=20
Local $newhigh=0
Local $countpoints = 0
Local $time = 1000  ;tooltip delay
Local $time2 = 1000  ; iequit relax time , 100 worked on netbook
local $time3 = 1   ; time offset to
local $starttime2
local $msg1 = "set speed"
Local $progresstime = 30
Local $stoploss = 0.30
Local $gamma = 0
Local $flash = "loading..."
Local $sign1 = "|"
Local $sign2 = "|"
Local $sign3 = "|"
Local $sign4 = "|"
Local $sign5 = "|"
Local $sign6 = "|"
Local $sign7 = "|"
Local $sign8 = "|"
Local $sign9 = "|"
Local $sign10 = "|"
Local $sign11 = "|"

Local $val1=$datapoint
Local $val2=$datapoint
Local $val3=$datapoint
Local $val4=$datapoint
Local $val5=$datapoint
Local $val6=$datapoint
Local $val7=$datapoint
Local $val8=$datapoint
Local $val9=$datapoint
Local $olddatapoint = $datapoint
Local $newdatapoint = $datapoint
Local $newhigh=$datapoint
$hFile = FileOpen(@ScriptDir & "dataruns" & @MON & "_" & @MDAY & "_" & @HOUR & "_" & @MIN & "_" & $var & ".log",9)
If $hFile = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
logit("<------------------------------ bought  " & $buypoint )
;--------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------
;                    run start

WHILE $go

   $countpoints = $countpoints + 1
   Local $starttime = _Timer_Init()
   $olddatapoint = $newdatapoint
   if $sign11 = "'" then
   $sign11 = "."
   Else
   $sign11 = "'"
   EndIf
;--------------------------------------------------------------------------------------------------------------
;                   fetch page and datapoint
  
   do
   do
   _IEAction($oIE, "refresh")
   until @error = 0
   ;sleep(2000)
  
  
   $oTable1 = _IETableGetCollection ($oIE,1); table 2 is where the price is om coloumn 1
   $aTableData1 = _IETableWriteToArray ($oTable1, True)
   $datapoint = $aTableData1[0][1]
   until $datapoint <= $olddatapoint*2 and $datapoint > 0; is data inside of range 0 to 200%
;-----------------------------------------------------------------------------------------------------------
;                   process datapoint
;
   $newdatapoint = $datapoint
   shifter()
   $val9 = $datapoint
   $gamma = int(((($val6 + $val7 + $val8 + $val9)-($val1 + $val2 + $val3 + $val4))/ _
   ($val1 + $val2 + $val3 + $val4))*1000)
   if $gamma > 1000 then $gamma = 1000
   If $gamma <-1000 then $gamma = -1000
   $momentgain = Round((($datapoint-$buypoint)/$buypoint)*100,1)
   if $datapoint > $newhigh then $newhigh = $datapoint
   if $newdatapoint > $olddatapoint then
   $sign10 = "'"
   ElseIf $newdatapoint < $olddatapoint then
   $sign10 = "."
   elseif $newdatapoint = $olddatapoint then
   $sign10 = "-"
   EndIf
   $flash = "   " & $momentgain & "% gain  " & $quantitystocks & "-" & $var & "  " & $gamma & "g  " & _
   $sign1 & $sign2 & $sign3 & $sign4 & $sign5 & $sign6 & $sign7 & $sign8 & $sign9 & $sign10 & "   " & _
   $buypoint & " --> " & $datapoint & "   " &  $countpoints & " ticks   " & _
   round((_Timer_Diff($starttime)/1000),1) & "s  " & $msg1 & "   " & $sign11 & $inst & $sign11 & "  "
  
   ToolTip ($flash, _
   @DesktopWidth-600,@DesktopHeight-(160+(20*$inst)),"",0,0)
   logit($flash)

   ;---------------------------------------------------------------------------------------------------------
   ;                   rules set
   ;

   switch $momentgain
    Case -5000 To -0.1
     $msg1 = "less than zero"
     $belowbuyout=5
     $gammaout=-10
     $ratchet=20
    Case 0 To 2.9
     $msg1 = "first speed"
     $belowbuyout=5
     $gammaout=-10
     $ratchet=80
    Case 3 To 5.9
     $msg1 = "second speed"
     $belowbuyout=0
     $gammaout=-10
     $ratchet=40
    Case 6 To 8.9
     $msg1 = "third speed"
     $belowbuyout=0
     $gammaout=-10
     $ratchet=40
    Case 9 To 11.9
     $msg1 = "fourth speed"
     $belowbuyout=0
     $gammaout=-10
     $ratchet=20
    Case 12 To 1000
     $msg1 = "fifth speed"
     $belowbuyout=0
     $gammaout=-10
     $ratchet=10
    Case Else
     $msg1 = "case else"
     $belowbuyout=0
     $gammaout=-10
     $ratchet=10
   EndSwitch
   ;-----------------------------------------------------------------------------------------------------------
   ;                   make decisions?
   ;
  
   if $countpoints > 5 and $datapoint < $buypoint* (1- $belowbuyout/100) then sell("stoploss  -->" & $datapoint)    ; hard stoploss
   if $gamma < $gammaout then sell("$gamma  < $gammaout   ->" & $gamma)
   if $datapoint < $newhigh-(($newhigh-$buypoint)*($ratchet/100)) then sell("ratchet sell on -> " & $msg1)     ;-----good
   if $time3 < $period then sleep($period-($time3*1000));<------------------------  period rotation set

;------------------------------------------------------------------------------------------------


WEND
;final report area
Exit
;------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------------------------------
;============================================================================================================
func logit($incoming)
   _FileWriteLog($hFile,$incoming) ; Write to the logfile passing the filehandle returned by FileOpen.
   TrayTip("","  !  ",1)
   sleep(300)
   TrayTip("","",1)
   Return
EndFunc
func sell($notes)
  
   logit("<------- sold from " & $notes)
   $profit = ($quantitystocks*$datapoint)-($quantitystocks*$buypoint)
   logit("overall profit per $1000 in is ---> " & $profit)
   ;logit("belowbuyout -> " & $belowbuyout & "gammaout ->" & $gammaout)
   ;FileClose($hFile) ; Close the filehandle to release the file
   msgbox(0,$notes,"selling now -> " & $var & " at profit of --> " & $profit,1)
   ;$go = 0
  
   ;Local $file = FileOpen("buy and sell records.txt", 1)
   ; Check if file opened for writing OK
  ; If $file = -1 Then
   ;MsgBox(0, "Error", "Unable to open file.")
  ; Exit
  ; EndIf
  ; FileWrite($file, $var & "   cdn$" & $buypoint & "<-bp   " & $notes & "  date:" &  _Now() & @CRLF)
   ;FileClose($file)
return
EndFunc
Func shifter()
   $sign1 = $sign2
   $sign2 = $sign3
   $sign3 = $sign4
   $sign4 = $sign5
   $sign5 = $sign6
   $sign6 = $sign7
   $sign7 = $sign8
   $sign8 = $sign9
   $sign9 = $sign10
  
   $val1 = $val2
   $val2 = $val3
   $val3 = $val4
   $val4 = $val5
   $val5 = $val6
   $val6 = $val7
   $val7 = $val8
   $val8 = $val9
  
   Return
EndFunc
Edited by Valik
Added code tag.
Link to comment
Share on other sites

This looks like it may be a caching issue with IE. You have set a lot of variables to equal until $datapoint, including $olddatapoint. Then you use _IETableGetCollection to get an update for $datapoint. If you are running multiple instances then these GETs(?) are likely using the same cached values from IE.

From the looks of it this feed you are getting these values from are likely JSON based, which are asynchronous. This allows the order in which they were sent by the server to differ from the order your browser receives or processes them in some cases. Personally I would probably parse the filtered output from something like ngrep for this.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...