Memory leaks occur when you don't free memory that you have allocated. All variables of base types that Pascal Script supports should be allocated and freed by the scripting engine (integers, floats, chars, strings, records, arrays, enums, sets). However, classes are something different. Classes are allocated by
.Create and should be freed by
.Free. If you do not free your memory, the application keeps allocating more and more memory until you run out.
My tip:
Only look at things you actually create (objects, bitmaps, dtms, files, etc.). Things like bitmaps, dtms and files are stored in an array in the Simba back end. It reuses empty spots. So if you want to check if you have a memory leak, just dump the index after you've created a bitmap/dtm/file. It should stabilize.
Simba Code:
program new;
var
a: Integer;
begin
a := BitmapFromString(2, 2, '');
WriteLn(a);
FreeBitmap(a);
a := BitmapFromString(2, 2, '');
WriteLn(a);
end.
a should be 0, because you've freed the first bitmap. If you hadn't done that, the index would've been 1.
If you are sure memory is leaking, and it's not coming from the script. Then it could be coming from a function in Simba or a leak in the scripting engine. Either way, it would be nice if you could single out the baddie
