Wizzup?
2011-02-09 05:44:50
If you see something like this when you stop your script:
You probably have a memory leak in your script. (Look at the insane amount of DTMs - it may be possible these are all globally in use, in which case you would not have to debug, but let's assume this is not the case)
Now, how can you debug this? The hard way would be to look at scripts and find all the points where you load a DTM or Bitmap, and then trace all possible routes the variable can go.
There is a slightly more simple method; Simba provides these two functions:
If you give each DTM you load a name; Simba will print it's name instead of the number when the script is terminated. This should (if used correctly) make debugging memory leaks a whole lot easier.
Example:
That's all, I just wanted to make you guys aware of this feature.
The following DTMs were not freed: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, SRL - Lamp bitmap, 82]
The following bitmaps were not freed: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, SRL - Mod bitmap, SRL - Admin bitmap]
File[C:\Simba\Includes\SRL/logs/SRL log 08-02-11 5.txt] has not been freed in the script, freeing it now.
You probably have a memory leak in your script. (Look at the insane amount of DTMs - it may be possible these are all globally in use, in which case you would not have to debug, but let's assume this is not the case)
Now, how can you debug this? The hard way would be to look at scripts and find all the points where you load a DTM or Bitmap, and then trace all possible routes the variable can go.
There is a slightly more simple method; Simba provides these two functions:
SetDTMName(DTM: Longint; name: string);
SetBitmapName(Bmp: Longint; name: string);
If you give each DTM you load a name; Simba will print it's name instead of the number when the script is terminated. This should (if used correctly) make debugging memory leaks a whole lot easier.
Example:
program new;
var bmp: integer;
begin
bmp:=CreateBitmap(42, 42);
setbitmapname(bmp, 'My 42x42 bitmap that I use to find black shields');
end.Compiled succesfully in 17 ms.
Successfully executed.
The following bitmaps were not freed: [My 42x42 bitmap that I use to find black shields]
That's all, I just wanted to make you guys aware of this feature.