SRL Archive - Help

How to Properly free DTM's and Bitmaps?


rj

2012-12-31 01:12:15

I have my own include:

var
Raw_Shark,Raw_RockTail,Raw_Manta:Integer;
Procedure CallFish;
begin
Raw_Shark := DTMFromString('mrAAAAHic42BgYDjLxMBwGoiPA/ExID4FxJeB+AIQXwPip4wMDG+A+C0QPwfih0D8CIhfQsVm9PYwFGRkMOSlpTHUlpSAaRC/va6WYVpPNwMn0A58mJEAhgEAVzIZUA==');
Raw_RockTail := DTMFromString('mlwAAAHicY2dgYPjJxMDwA4j/QTGI/xmKXzEyMDwC4qdA/BKIPwHxOyhbT0Wewd5UhUFDXpDBO86bYfWJNQxa8lIMhfH2DJxAc3FhRjwYCgAdQxN4');
Raw_Manta := DTMFromString('mlwAAAHicY2dgYFjKxMCwDIhXAfEaIF4OxAuBeD4QP2dkYHgAxI+B+CUQvwbit0D8FIiTMyaDsW9QMYO3fwFDdEI7mF9UuYKBE2guLsyIB0MBAOCeFEY=');
end;
Begin
CallFish;
repeat
CallFish;
Freedtm(Raw_Shark);
Freedtm(Raw_RockTail);
Freedtm(Raw_Manta);
until false
end.

And it always says I am not freeing the Bitmaps, How else am I supposed to lol

Wardancer

2012-12-31 01:21:02

I don't mean to be rude, but there are dozens of threads about this subject already. Could you, please, use the forum search engine a bit more? By asking questions like this, it really doesn't make people want to help. At least, not me.

However, I've seen you attempt to be helpful on other threads so I shall still give you a hand this time. The issue is quite simple. You call the procedure CallFish before entering the loop. Basically, you already have each DTM called twice before you start freeing them.

You probably could have seen the problem with better standards =p.

rj

2012-12-31 01:24:10

From: Wardancer
I don't mean to be rude, but there are dozens of threads about this subject already. Could you, please, use the forum search engine a bit more? By asking questions like this, it really doesn't make people want to help. At least, not me.

However, I've seen you attempt to be helpful on other threads so I shall still give you a hand this time. The issue is quite simple. You call the procedure CallFish before entering the loop. Basically, you already have each DTM called twice before you start freeing them.

You probably could have seen the problem with better standards =p.


Thanks but it is still not freeing one of the DTM's [0]

Wardancer

2012-12-31 01:25:42

From: rjj95
Thanks but it is still not freeing one of the DTM's [0]


Only because it hadn't freed that DTM when you pressed stop. Try it a few times and you'll see that DTM freed at times.

Runehack123

2012-12-31 02:05:08

What to do (basically):

-Create function that calls on all DTMs
-Create function that frees all DTMs

then:

main

>>Call on DTMs

>>Repeat X

>>Free DTMs

This is what you shouldn't do:

main

Repeat
>> Call on DTMs
>> Repeat X
>> Free DTMs


So basically anything that involves calling on DTMs within a loop! No need for all that unnecessary work!

Finally, use
Addonterminate(); along with your DTM freeing function
to make sure all DTMs are freed at the end of the script!

Good luck and happy scripting my friend.

superuser

2012-12-31 02:26:07

Hi!

To ensure you are freeing your stuff, you can create OnTerminate event procedure which does the magic. Something like this:

program foobar;

var
raw_shark,
raw_rocktail,
raw_manta: integer;

procedure OnTerminate(const f: string);
var
current: TVariantArray;
i: integer;
begin
GetScriptProp(SP_OnTerminate, current); // Get the current list of functions.

for i := 0 to High(current) do
if Lowercase(current[i]) = Lowercase(f) then
exit; // Function was already in the list.

SetLength(current, Length(current) + 1);

current[High(current)] := f;

SetScriptProp(SP_OnTerminate, current);
end;

procedure CleanMyInclude();
begin
WriteLn('Cleaning...');

if raw_shark > 0 then
FreeDTM(raw_shark);

if raw_rocktail > 0 then
FreeDTM(raw_rocktail);

if raw_manta > 0 then
FreeDTM(raw_manta);
end;

procedure InitMyInclude();
begin
ClearDebug();

WriteLn('Initializing...');

raw_shark := DTMFromString('mrAAAAHic42BgYDjLxMBwGoiPA/ExID4FxJeB+AIQXwPip4wMDG+A+C0QPwfih0D8CIhfQsVm9PYwFGRkMOSlpTHUlpSAaRC/va6WYVpPNwMn0A58mJEAhgEAVzIZUA==');
raw_rocktail := DTMFromString('mlwAAAHicY2dgYPjJxMDwA4j/QTGI/xmKXzEyMDwC4qdA/BKIPwHxOyhbT0Wewd5UhUFDXpDBO86bYfWJNQxa8lIMhfH2DJxAc3FhRjwYCgAdQxN4');
raw_manta := DTMFromString('mlwAAAHicY2dgYFjKxMCwDIhXAfEaIF4OxAuBeD4QP2dkYHgAxI+B+CUQvwbit0D8FIiTMyaDsW9QMYO3fwFDdEI7mF9UuYKBE2guLsyIB0MBAOCeFEY=');

OnTerminate('CleanMyInclude');
end;

begin
InitMyInclude();
end.

CRASH_OVERRIDE

2012-12-31 03:07:20

From: superuser
Hi!

To ensure you are freeing your stuff, you can create OnTerminate event procedure which does the magic. Something like this:

program foobar;

var
raw_shark,
raw_rocktail,
raw_manta: integer;

procedure OnTerminate(const f: string);
var
current: TVariantArray;
i: integer;
begin
GetScriptProp(SP_OnTerminate, current); // Get the current list of functions.

for i := 0 to High(current) do
if Lowercase(current[i]) = Lowercase(f) then
exit; // Function was already in the list.

SetLength(current, Length(current) + 1);

current[High(current)] := f;

SetScriptProp(SP_OnTerminate, current);
end;

procedure CleanMyInclude();
begin
WriteLn('Cleaning...');

if raw_shark > 0 then
FreeDTM(raw_shark);

if raw_rocktail > 0 then
FreeDTM(raw_rocktail);

if raw_manta > 0 then
FreeDTM(raw_manta);
end;

procedure InitMyInclude();
begin
ClearDebug();

WriteLn('Initializing...');

raw_shark := DTMFromString('mrAAAAHic42BgYDjLxMBwGoiPA/ExID4FxJeB+AIQXwPip4wMDG+A+C0QPwfih0D8CIhfQsVm9PYwFGRkMOSlpTHUlpSAaRC/va6WYVpPNwMn0A58mJEAhgEAVzIZUA==');
raw_rocktail := DTMFromString('mlwAAAHicY2dgYPjJxMDwA4j/QTGI/xmKXzEyMDwC4qdA/BKIPwHxOyhbT0Wewd5UhUFDXpDBO86bYfWJNQxa8lIMhfH2DJxAc3FhRjwYCgAdQxN4');
raw_manta := DTMFromString('mlwAAAHicY2dgYFjKxMCwDIhXAfEaIF4OxAuBeD4QP2dkYHgAxI+B+CUQvwbit0D8FIiTMyaDsW9QMYO3fwFDdEI7mF9UuYKBE2guLsyIB0MBAOCeFEY=');

OnTerminate('CleanMyInclude');
end;

begin
InitMyInclude();
end.



Could this also work for bitmaps? i free my dtms on termination and still seem to get bitmap errors when manually stopping my script:/

Wardancer

2012-12-31 03:16:37

From: tasmania
Could this also work for bitmaps? i free my dtms on termination and still seem to get bitmap errors when manually stopping my script:/


A few errors are client based. I believe we all get those:

The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap, SRL - NavBar Bitmap, SRL - Options Bitmap]

CRASH_OVERRIDE

2012-12-31 03:19:38

From: Wardancer
A few errors are client based. I believe we all get those:

The following DTMs were not freed: [SRL - Lamp bitmap, 1]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap, SRL - NavBar Bitmap, SRL - Options Bitmap]


Kool.:duh: