SRL Archive - Bugs

Massive Memory Leak in Objects.simba


Bad Boy JH

2011-03-07 03:04:42

during a procedure which is almost exclusivly dealing with objects, my memory usage went from 169,000 to 411,000.

Here is procedure


function R_BestYCoordinate(MinY, MaxY: Integer): Integer;
{checks the coordinates between MinY and MaxY to
see which row has the least fires on them.}
var
I: Integer;
Possibles, FiresOnLine: TIntegerArray;
Fires: TRSObjectArray;
begin
Fires := GetObjectsByID(FireID, 0, 50);
SetLength(FiresOnLine, MaxY - MinY + 1);
for I := 0 to High(Fires) do
if InRange(Fires[I].Tile.y, MinY, MaxY) then
Inc(FiresOnLine[Fires[i].Tile.y - MinY]);
for I := 0 to High(FiresOnLine) do
if (FiresOnLine[i] = TMin(FiresOnLine)) then
Possibles := CombineIntArray(Possibles, [I]);
Fires := []; //Im even trying to free them here! no effect
Result := Possibles[Random(Length(Possibles))] + MinY;
end;

TomTuff

2011-03-07 03:07:08

it doesn't work 100% of the time for me, but it does work sometimes. I do this:

function Example: Boolean;
var
Ojs: TRSObjectArray;
i: Integer;
begin
//Finding npcs
NPCs := GetAllObjects(333);
//Do what you need to
//free them
for i := 0 to High(Objs) do
NPCs[i] := NULL_RSOBJECT;
SetLength(Objs, 0);
end;

Harry

2011-03-07 03:14:36

Setting the length to 0 seems to work more often than := [];. Wish I knew how to fix it.

mastaraymond

2011-03-07 10:30:00

Is it possible this is an error within Pascal Script?

Wizzup?

2011-03-07 11:01:26

From: Bad Boy JH
during a procedure which is almost exclusivly dealing with objects, my memory usage went from 169,000 to 411,000.

Here is procedure


function R_BestYCoordinate(MinY, MaxY: Integer): Integer;
{checks the coordinates between MinY and MaxY to
see which row has the least fires on them.}
var
I: Integer;
Possibles, FiresOnLine: TIntegerArray;
Fires: TRSObjectArray;
begin
Fires := GetObjectsByID(FireID, 0, 50);
SetLength(FiresOnLine, MaxY - MinY + 1);
for I := 0 to High(Fires) do
if InRange(Fires[I].Tile.y, MinY, MaxY) then
Inc(FiresOnLine[Fires[i].Tile.y - MinY]);
for I := 0 to High(FiresOnLine) do
if (FiresOnLine[i] = TMin(FiresOnLine)) then
Possibles := CombineIntArray(Possibles, [I]);
Fires := []; //Im even trying to free them here! no effect
Result := Possibles[Random(Length(Possibles))] + MinY;
end;


Don't you have to free all objects with SmartFreeObject?

Flight

2011-03-07 11:13:37

I wonder if this is where I'm going wrong with my LandScorcher script. I know it's something I must have over-looked with reflection, because it doesn't seem to last but just a matter of minutes before Smart and Simba crash on me. If someone wants to take a look at it or test it and tell me what you think, that'd be wonderful. I'm still very new to reflection, so bare with me. :unsure:

Coh3n

2011-03-07 13:14:34

Just a suggestion, but if you're having trouble with objects, you can always use TileToMS and check for uptext of the object. It's what I do and it hasn't failed me yet.

Flight

2011-03-07 19:25:44

Yep I have the TileToMS and even TileToMM if the tile isn't in view on the main screen.