Posted: Sun Mar 23, 2003 7:51 pm
Restored from previous forum. Originally posted by LJ.
There is another leak on the same code, only an read statement is used with an array. The code is below. Keep clicking on the button and about every 3 clicks the .exe increases about 4K. This is the same code in the previous example that has no leak by Timo. The only difference is that I've added a READ command, it is as if the .s ARRAY in the UpdateScreen is not clearing itself.
Dim talk.s(18)
Dim prof.s(10)
OpenWindow(1, 128, 96, 320, 256, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget, "Background image example")
CreateGadgetList(WindowID())
CreateImage(1, WindowWidth(), WindowHeight())
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(LoadFont(0, "Times New Roman", 16))
Locate(64, 32)
DrawText("Background image")
StopDrawing()
ImageGadget(1, 0, 0, WindowWidth(), WindowHeight(), UseImage(1))
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
LoadFont(0, "Times New Roman", 16)
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 0
Gosub UpdateWindow
EndSelect
EndIf
Until EventID=#PB_EventCloseWindow
End
UpdateWindow:
FreeGadget(0)
UseImage(1)
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(UseFont(0))
Locate(64, 32)
DrawText("Test image")
StopDrawing()
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
Restore screen1
For k = 1 To 17
Read tmp.s
talk(k)=tmp
Next k
talklines = 0
For k = 1 To 10
Read tmp.s
prof(k)=tmp
talklines = talklines + 1
If prof(k) = ""
talklines = talklines - 1
EndIf
Next k
SetGadgetState(1, UseImage(1))
ActivateGadget(0)
Return
DataSection
screen1:
Data.s "Sample data that the program is reading."
Data.s ""
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s ""
Data.s ""
Data.s ""
EndDataSection
There is another leak on the same code, only an read statement is used with an array. The code is below. Keep clicking on the button and about every 3 clicks the .exe increases about 4K. This is the same code in the previous example that has no leak by Timo. The only difference is that I've added a READ command, it is as if the .s ARRAY in the UpdateScreen is not clearing itself.
Dim talk.s(18)
Dim prof.s(10)
OpenWindow(1, 128, 96, 320, 256, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget, "Background image example")
CreateGadgetList(WindowID())
CreateImage(1, WindowWidth(), WindowHeight())
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(LoadFont(0, "Times New Roman", 16))
Locate(64, 32)
DrawText("Background image")
StopDrawing()
ImageGadget(1, 0, 0, WindowWidth(), WindowHeight(), UseImage(1))
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
LoadFont(0, "Times New Roman", 16)
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 0
Gosub UpdateWindow
EndSelect
EndIf
Until EventID=#PB_EventCloseWindow
End
UpdateWindow:
FreeGadget(0)
UseImage(1)
StartDrawing(ImageOutput())
Box(0, 0, WindowWidth(), WindowHeight(), $ff)
FrontColor(0, 0, 0)
DrawingMode(1)
DrawingFont(UseFont(0))
Locate(64, 32)
DrawText("Test image")
StopDrawing()
ButtonGadget = ButtonGadget(0, 80, 64, 160, 128, "My Button")
Restore screen1
For k = 1 To 17
Read tmp.s
talk(k)=tmp
Next k
talklines = 0
For k = 1 To 10
Read tmp.s
prof(k)=tmp
talklines = talklines + 1
If prof(k) = ""
talklines = talklines - 1
EndIf
Next k
SetGadgetState(1, UseImage(1))
ActivateGadget(0)
Return
DataSection
screen1:
Data.s "Sample data that the program is reading."
Data.s ""
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s ""
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s "Sample data that the program is reading."
Data.s ""
Data.s ""
Data.s ""
EndDataSection