Freeing the form frees all it's components/children.
Freeing the form frees all it's components/children.
SRL's F.A.Q. (Error fixes) | How to Convert SRL-5 Scripts to SRL-6 | Draynor Chop N' Bank (RS3)| AIO Superheater (RS3)
T - E - A - MTogether Everyone Achieves More
Woah! What could possibly be causing an increase of memory use THAT much in object tracking?
I'm surprised..
Forget everything I said in the above posts, I found the problem, and it's not with MSI. It's with paintsmart.scar. I added writeln's to all the try..except statements in the paintsmart.scar functions, and none were being freed.
I'm surprised I didn't think of this earlier. Guess no one put together to dots.Progress Report:[0:00:17]: SMART BITMAP NOT FREED [0:00:17]: SMART BITMAP NOT FREED [0:00:17]: SMART BITMAP NOT FREED [0:00:17]: SMART BITMAP NOT FREED [0:00:17]: SMART BITMAP NOT FREED [0:00:17]: SMART BITMAP NOT FREED [0:00:17]: SMART BITMAP NOT FREED [0:00:17]: SMART BITMAP NOT FREED [0:00:17]: SMART BITMAP NOT FREEDNow how to fix it..
The functions call FreeBitmap(drawing) and drawing is a TBitmap, so I changed all the FreeBitmaps to drawing.free and it got rid of the error, but nothing gets painted on SMART, so some edits will have to be made. The important thing is the issue has been found.![]()
SRL's F.A.Q. (Error fixes) | How to Convert SRL-5 Scripts to SRL-6 | Draynor Chop N' Bank (RS3)| AIO Superheater (RS3)
T - E - A - MTogether Everyone Achieves More
Yes! Good job
Hopefully this will get rid of most of the memory leaks![]()
Simba Code://-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- � Smart Painting routines --//
//-----------------------------------------------------------------//
// procedure ClearCanvas(Canvas: TCanvas; W, H: integer); //
// procedure ClearRSCanvas(canvas: TCanvas); //
// procedure DrawDotsEx(Clear: boolean; Pixels: T2DPointArray); //
// procedure SMART_DrawDotsEx(Clear: boolean; pixels: TPointArray; color: TColor); //
// procedure SMART_DrawDots(Dots: TPointArray); //
// procedure SMART_DrawBoxEx(Clear: boolean; Box: TBox; color: TColor); //
// procedure SMART_DrawBox(Box: TBox); //
// procedure SMART_DrawTextEx(Clear: Boolean; X, Y: Integer; Font, Text: string; Color: TColor); //
// procedure SMART_DrawText(X, Y: Integer; Font, Text: string; Color: TColor); //
//-----------------------------------------------------------------//
{*******************************************************************************
procedure ClearCanvas(Canvas: TCanvas; W, H: integer);
Contributors: Sir R. Magician, mastaraymond
Description: Clears a canvas of dimensions (w, h)
*******************************************************************************}
procedure ClearCanvas(Canvas: TCanvas; W, H: integer);
var
CleanBMP: integer;
begin
try
try
CleanBMP := BitmapFromString(W, H, '');
{$IFNDEF SIMBA}Safe{$ENDIF}DrawBitmap(CleanBMP, Canvas, 0, 0);
finally
FreeBitmap(CleanBMP);
end;
except
WriteLn(ExceptionToString(ExceptionType, ExceptionParam));
end;
end;
{*******************************************************************************
procedure ClearRSCanvas(Canvas: TCanvas);
Contributors: Sir R. Magician
Description: Clears a canvas of RS dimensions
*******************************************************************************}
procedure ClearRSCanvas(Canvas: TCanvas);
begin
ClearCanvas(Canvas, MIX2 + 100, MIY2 + 100);
end;
{*******************************************************************************
procedure DrawDotsEx(Clear: boolean; Pixels: T2DPointArray);
Contributors: Sir R. Magician
Description: Draws an ATPA onto the SMART Debug canvas
*******************************************************************************}
procedure DrawDotsEx(Clear: boolean; Pixels: T2DPointArray);
{$IFDEF SMART}
var
I, J, H, K, Color: integer;
begin
with TBitmap.Create do
try
try
Canvas.Handle := SmartGetDebugDC;
if (Clear) then
ClearRSCanvas(Canvas);
H := High(Pixels);
for I := 0 to H do
begin
Color := I div 5 + I mod 5;
case Color of
0: Canvas.Pen.Color := clWhite;
1: Canvas.Pen.Color := clYellow;
2: Canvas.Pen.Color := clBlue;
3: Canvas.Pen.Color := clLime;
4: Canvas.Pen.Color := clGreen;
end;
K := High(Pixels[I]);
for J := 0 to K do
begin
Canvas.MoveTo(Pixels[I][J].x - 1, Pixels[I][J].y);
Canvas.LineTo(Pixels[I][J].x, Pixels[I][J].y);
end;
end;
except
WriteLn(ExceptionToString(ExceptionType, ExceptionParam));
end;
finally
Free;
end;
{$ELSE}
begin
{$ENDIF}
end;
{*******************************************************************************
procedure SMART_DrawDotsEx(Clear: boolean; Pixels: TPointArray; Color: TColor);
Contributors: Sir R. Magician, caused, mastaraymond
Description: Draws a TPA onto the SMART Debug canvas
*******************************************************************************}
procedure SMART_DrawDotsEx(Clear: boolean; Pixels: TPointArray; Color: TColor);
{$IFDEF SMART}
var
I, H: integer;
begin
with TBitmap.Create do
try
try
Canvas.Handle := SmartGetDebugDC;
Canvas.Pen.Color := Color;
if (Clear) then
ClearRSCanvas(Canvas);
H := High(Pixels);
for I := 0 to H do
begin
Canvas.MoveTo(Pixels[I].x - 1, Pixels[I].y);
Canvas.LineTo(Pixels[I].x, Pixels[I].y);
end;
except
WriteLn(ExceptionToString(ExceptionType, ExceptionParam));
end;
finally
Free;
end;
{$ELSE}
begin
{$ENDIF}
end;
{*******************************************************************************
Procedure SMART_DrawDots(Dots: TPointArray);
Contributors: Sir R. Magician
Description: Draws a TPA onto the SMART Debug canvas
*******************************************************************************}
procedure SMART_DrawDots(Dots: TPointArray);
begin
SMART_DrawDotsEx(True, Dots, clRed);
end;
{*******************************************************************************
procedure SMART_DrawBoxEx(Clear: boolean; Box: TBox; Color: TColor);
Contributors: Sir R. Magician, caused, mastaraymond
Description: Draws a TBox onto the SMART Debug canvas
*******************************************************************************}
procedure SMART_DrawBoxEx(Clear: boolean; Box: TBox; Color: TColor);
begin
{$IFDEF SMART}
with TBitmap.Create do
try
try
Canvas.Handle := SmartGetDebugDC;
Canvas.Pen.Color := Color;
if (Clear) then
ClearRSCanvas(Canvas);
Canvas.MoveTo(Box.x1, Box.y1);
Canvas.LineTo(Box.x2, Box.y1);
Canvas.LineTo(Box.x2, Box.y2);
Canvas.LineTo(Box.x1, Box.y2);
Canvas.LineTo(Box.x1, Box.y1);
except
WriteLn(ExceptionToString(ExceptionType, ExceptionParam));
end;
finally
Free;
end;
{$ENDIF}
end;
{*******************************************************************************
procedure SMART_DrawBox(Box: TBox);
Contributors: Sir R. Magician
Description: Draws a TBox onto the SMART Debug canvas
*******************************************************************************}
procedure SMART_DrawBox(Box: TBox);
begin
SMART_DrawBoxEx(True, Box, clRed);
end;
{*******************************************************************************
procedure SMART_DrawTextEx(Clear: Boolean; X, Y: Integer; Font, Text: string; Color: TColor);
Contributors: Jukka, Shuttleu
Description: Draws text onto the SMART Debug canvas at position x, y
*******************************************************************************}
procedure SMART_DrawTextEx(Clear: Boolean; X, Y: Integer; Font, Text: string; Color: TColor);
var
I, H, Height: integer;
TPA: TPointArray;
begin
TPA := LoadTextTPA(Text, Font, Height);
H := High(TPA);
for I := 0 to H do
begin
IncEx(TPA[I].x, X);
IncEx(TPA[I].y, Y);
end;
SMART_DrawDotsEx(Clear, TPA, Color);
end;
{*******************************************************************************
procedure SMART_DrawText(X, Y: Integer; Font, Text: string; Color: TColor);
Contributors: Shuttleu
Description: Draws text onto the SMART Debug canvas at position x, y
*******************************************************************************}
procedure SMART_DrawText(X, Y: Integer; Font, Text: string; Color: TColor);
begin
SMART_DrawTextEx(False, X, Y, Font, Text, Color);
end;
Dgby, since you're freeing the bitmap at the end of the procedure, wouldn't that clear the canvas (i.e. nothing would be shown)? See this.
SRL's F.A.Q. (Error fixes) | How to Convert SRL-5 Scripts to SRL-6 | Draynor Chop N' Bank (RS3)| AIO Superheater (RS3)
T - E - A - MTogether Everyone Achieves More
Hey any of u know if its possible to free a dtm or bitmap ON TERMINATE? I dont mean having the script terminate itself but I mean when the user presses the stop button, it free's that stuff.. that way wouldnt it stop the memory leaks??
And btw I believe drawing a blank bitmap on top of an existing one will pile the memory... U actually need to completely delete it from memory.. wipe it from existance as if it was never drawn before..
Last edited by Brandon; 04-01-2011 at 04:09 PM.
SRL's F.A.Q. (Error fixes) | How to Convert SRL-5 Scripts to SRL-6 | Draynor Chop N' Bank (RS3)| AIO Superheater (RS3)
T - E - A - MTogether Everyone Achieves More
"No."?
Mind explaining why? Because when I freed the TBitmap at the end of the procedures in the current version, nothing was displayed, which makes sense in my mind. I can see that you wrote it a little differently, but to me it looks like it does the same thing, just in a different way.
SRL's F.A.Q. (Error fixes) | How to Convert SRL-5 Scripts to SRL-6 | Draynor Chop N' Bank (RS3)| AIO Superheater (RS3)
T - E - A - MTogether Everyone Achieves More
Lol well okay! Awesome then. I'll test when I get home to make sure there aren't any leaks. Thank.![]()
SRL's F.A.Q. (Error fixes) | How to Convert SRL-5 Scripts to SRL-6 | Draynor Chop N' Bank (RS3)| AIO Superheater (RS3)
T - E - A - MTogether Everyone Achieves More
There are currently 1 users browsing this thread. (0 members and 1 guests)