SRL Archive - OSR Help

Memory leak


Shatterhand

2012-12-17 04:09:15

I have a problem with my script. RAM usage is going up very fast and after like 5 hours simba crashes with some error that it could not make the thread. RAM usage is usually at 1300-1500MB at that time. (for simba.exe *32)
I already checked DTMs, Bitmaps but found no problem.
Any suggestions? :)
EDIT: uploaded code.

superuser

2012-12-17 04:22:37

Impossible to say without code.

Sin

2012-12-17 06:57:40

Happens to me too :(

riwu

2012-12-17 06:59:22

Use wrappers:
eg. SplitTPAWrap instead of SplitTPA.

NKN

2012-12-17 07:05:41

Watch out for SMART_Graphics if you use it, they leak really bad.

Mr[S]

2012-12-17 07:43:54

Success, NKN now has 78 internets.

I gave you an internet for that :spongebob:

Olly

2012-12-17 11:23:21

Yeah there's a small memory leak in smart_graphics which Brandon sent a pull request but hasn't get been accepted… and use all tpa wrapper functions you can.

Shatterhand

2012-12-17 11:29:25

SMART_Graphics means all the paint on smart? I started using those wrappers. Thanks for the answers.

Olly

2012-12-17 12:04:02

Im not sure how many but here's the pull request

https://github.com/SRL/SRL-5/pull/128

Google

2012-12-17 12:08:00

smart_drawtextex and drawtext are causing majority of the code 8 errors most users are having.

Shatterhand

2012-12-17 15:23:47

Using SplitTPAWraps, turned off all the paintsmart stuff and everything is fine.

Sin

2012-12-17 15:28:30


???

Was using Ashaman's Herblore script, and as far as I know he doesn't use Paint smart and/o TPAs…

Ashaman88

2012-12-17 15:35:57

From: Shay

???

Was using Ashaman's Herblore script, and as far as I know he doesn't use Paint smart and/o TPAs…


Yeah I'm pretty sure that one only uses the includes functions…

superuser

2012-12-17 15:44:05

From: Ashaman88
Yeah I'm pretty sure that one only uses the includes functions…


unfortunately srl is full of leaks and bad coding. for instance, i had to rewrite most of the functions to my latest script just to avoid leaks etc.

Le Jingle

2012-12-17 15:56:11

I don't know if this helps the include functions, but it sure does help some script functions that leak; It was introduced via Markus on this thread..

Note, placement in the script;


{$IFDEF RAYMONDPOWNS}{wrappers} function FloodFillTPAWrap(const TPA: TPointArray): T2DPointArray; var tempATPA: T2DPointArray; begin tempATPA:= FloodFillTPA(TPA); Result:= tempATPA; SetLength(tempATPA, 0); end; function FindTPAEdges(const p: TPointArray): TPointArray; begin FindTPAEdgesWrap(p, result); end; Function RotatePoints(Const P: TPointArray; A, cx, cy: Extended): TPointArray; begin RotatePointsWrap(P, A, cx, cy, result); end; function TPAFromCircle(const CX, CY, Radius: Integer): TPointArray; begin TPAFromCircleWrap(CX, CY, Radius, result); end; function TPAFromEllipse(const CX, CY, XRadius, YRadius : Integer): TPointArray; begin TPAFromEllipseWrap(CX, CY, XRadius, YRadius, result); end; function TPAFromBox(const Box : TBox) : TPointArray; begin TPAFromBoxWrap(Box, result); end; Function ReturnPointsNotInTPA(Const TotalTPA: TPointArray; const Box: TBox): TPointArray; begin ReturnPointsNotInTPAWrap(TotalTPA, Box, result); end; function CombineIntArray(const Ar1, Ar2: TIntegerArray): TIntegerArray; begin CombineIntArrayWrap(Ar1, Ar2, result); end; function ReArrangeandShortenArray(const a: TPointArray; Dist: Integer): TPointArray; begin ReArrangeandShortenArrayWrap(a, Dist, result); end; function ReArrangeandShortenArrayEx(const a: TPointArray; w, h: Integer): TPointArray; begin ReArrangeandShortenArrayExWrap(a, w, h, result); end; function CombineTPA(const Ar1, Ar2: TPointArray): TPointArray; begin CombineTPAWrap(Ar1, Ar2, Result); end; function RemoveDistTPointArray(x, y, dist: Integer;const ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray; begin RemoveDistTPointArrayWrap(x, y, dist, ThePoints, RemoveHigher, Result); end; function TPAFromText(const text, font: String; var w,h: Integer): TPointArray; begin TPAFromTextWrap(text, font, w, h, result); end; function GetColors(const Coords: TPointArray): TIntegerArray; begin GetColorsWrap(Coords, Result); end; function Explode(del, str: string): TStringArray; begin ExplodeWrap(del, str, Result); end; function MergeATPA(const ATPA : T2DPointArray): TPointArray; begin MergeATPAWrap(ATPA, Result); end; function SplitTPA(arr : TPointArray; dist : Integer) : T2DPointArray; begin SplitTPAWrap(arr, dist, result); end; function SplitTPAEx(arr : TPointArray; w, h : integer) : T2DPointArray; begin SplitTPAExWrap(Arr, w, h, result); end; function ClearTPAFromTPA(arP, ClearPoints : TPointArray) : TPointArray; begin ClearTPAFromTPAWrap(arP, ClearPoints, result); end; function TPAToATPAEx(arP : TPointArray; w, h : integer) : T2DPointArray; begin TPAtoATPAExWrap(arP, w, h, result); end; function TPAToATPA(arP : TPointArray; dist : Integer) : T2DPointArray; begin TPAtoATPAWrap(arP, dist, result); end; function FindGapsTPA(TPA : TPointArray; MinPixels : integer) : T2DPointArray; begin FindGapsTPAWrap(tpa, MinPixels, result); end; {$ENDIF}
{$DEFINE SMART}
{$i srl/srl.simba}

Helps with some TPA usage.

*Think it was also in Markus's Ess Miner and maybe by Riwu too? I forget :s

Olly

2012-12-17 19:20:25

From: superuser
unfortunately srl is full of leaks and bad coding. for instance, i had to rewrite most of the functions to my latest script just to avoid leaks etc.


Should make a topic on this or commit fixes :)