SRL Archive - Reflection Help

Out of memory at line 107


Harry

2011-01-20 14:27:13

Error: Exception: Out of memory at line 107

Happens into GroundItems. Randomly happens every few hours. Possible memleak? How to fix it?

mormonman

2011-01-20 16:46:00

Do you set your GroundItemArray := []; ? After everytime you call it?

Harry

2011-01-20 16:53:39

From: mormonman
Do you set your GroundItemArray := []; ? After everytime you call it?

I don't. I do setArray(var,0), however.

procedure TeleHelms;
var
items: TGroundItemArray;
begin
setlength(items, 0);
is a snip of it (lesser demon script). I set the length to 0 every time the procedure is called at the beginning. Is there some other way I should be setting it?

mormonman

2011-01-20 16:56:09

From: Harry
I don't. I do setArray(var,0), however.

procedure TeleHelms;
var
items: TGroundItemArray;
begin
setlength(items, 0);
is a snip of it (lesser demon script). I set the length to 0 every time the procedure is called at the beginning. Is there some other way I should be setting it?


After you use the array just do items := [];

Harry

2011-01-20 16:58:39

SetLength to 0 does the same thing, no? :confused:

mormonman

2011-01-20 17:13:29

Yes it does, but you have to call it after you use the array, not at the beginning of the procedure. Just trust me.

Nava2

2011-01-20 18:12:09

From: mormonman
Yes it does, but you have to call it after you use the array, not at the beginning of the procedure. Just trust me.


That does not make sense.

PS should be freeing the Records after all references to them deplete.

tarajunky

2011-01-20 20:52:37

I still have this same error, and I do set := [] after the function completes.

pyroryan

2011-01-20 21:17:41

SmartFreeObject(next);
Thats the only thing not freed.

Edit:
Committed to the SVN.

Method

2011-01-21 00:04:14

From: pyroryan
SmartFreeObject(next);
Thats the only thing not freed.

Edit:
Committed to the SVN.


Isn't it, though? Each iteration of the loop, cur is freed (which should free the previous next element, no?) and then set to the current next element. After the loop, cur is freed once more, since it wouldn't have been freed during the last iteration of the loop.

Harry

2011-01-21 04:55:06

From: pyroryan
SmartFreeObject(next);
Thats the only thing not freed.

Edit:
Committed to the SVN.

Whilst I appreciate the commit, it's doing worse than good, I think. It makes the script freeze forever. Removing the newly added SmartFreeObject(next)'s fixes the infinite-waiting problem.

So I guess deal with a memleak or have an infinite waiting loop… I choose the memleak ;)

pyroryan

2011-01-21 11:03:28

From: Method
Isn't it, though? Each iteration of the loop, cur is freed (which should free the previous next element, no?) and then set to the current next element. After the loop, cur is freed once more, since it wouldn't have been freed during the last iteration of the loop.


I don't know pascal very well, so I couldn't tell you. I'll revert once I get back. On my phone atm. Seems like you're correct though since it crashes more than it used to.

Edit:
Never mind what I said, its not even pascal. But yes, you are correct. The reference would be deleted as storing would not generate another reference. Sorry for any confusion lol :P.