SRL Archive - General

Can't allocate DIB handle error


Freddy1990

2010-04-20 06:47:31

Hey everyone,

It has been quite a while since I last posted here, this being because it was made very clear that I'm not exactly welcome here anymore. However, I had something important to share… I was recently pondering about the "Can't allocate DIB handle" error for which I've received quite a lot of heat because I could never find what actually caused it… I thought I had at one point, but it appeared that I had not afterwards. This error is thrown by SCAR when it can't allocate a DIB handle, obviously, what this means though, is that Windows won't allow the application to create any more bitmaps. There's few reasons what could possibly trigger this, the only viable reason is that SCAR would be creating bitmaps in it's memory space and not free them afterwards, which eventually would pile up until Windows gets fed up with it and refuses to allow any more to be created. So, I went looking in SCAR's source for any bitmaps I might not be freeing, though me and kaitnieks never really left that many memory leaks and I fixed most of the leaks in there years ago. And my search came up empty. So I started thinking… SCAR's plugin system works in a way that plugins are loaded to share the same memory space SCAR does, and this error has as far as I know only been known to occur for SRL users… So I turned my attention towards the SRL plugins, and I found this: http://villavu.com/repositories/srl-opendev/place%20inside%20plugins%20folder/WizzyPlugin.dpr, if you would scroll down to CreateTPAFromBMP, you'll notice a bitmap "Bitmappie", being created without being freed afterwards, now if this function is called repeatedly enough, this would cause the very problem of "Can't allocate DIB handle" in SCAR. So my conclusion is, I'm not sure if it's the actual cause, but I really can't find anything else that could cause it, unless SCAR is actually handling too many bitmaps at once, but that also seems very unlikely, because that would be a shitload of bitmaps… But in any case, it has to be fixed because it creates a serious memory leak in SCAR's memory space.

Yours truly,
Freddy.

Frement

2010-04-20 06:54:56

To think of it, I havent gotten the problem much lately.

From: Freddy1990
this being because it was made very clear that I'm not exactly welcome here anymore.

Whats with that?

Nava2

2010-04-20 08:48:11

Cheers, thanks for posting this!

Its appreciated.

For the record, this is already fixed in Simba, unknowingly I guess.

I will fix it later for SCAR.

Drunkenoldma

2010-04-20 09:11:09

Wall of text crits you for 9001!

On a more serious note:
Why aren't you welcome here anymore?

Wizzup?

2010-04-20 09:31:07

This is only called in one place in SRL. In CreateTPAFromText. CreateTPAFromText is only called in Players.scar, to initialize the Player's nick TPA. SRL uses it only for initialization. (As far as my quick grep could show anyway)
So unless some scripts use this extensively, this can't be the cause of the errors in SCAR.

Tim0suprem0

2010-04-20 12:41:34

Woo hi freddy! Why aren't you welcome here anymore :(

Frement

2010-04-20 15:05:52

I actually get the DIB handle error when i try to read text, like hovering a skill and reading the text.

Timer

2010-04-20 15:15:34

From: Wizzup?
This is only called in one place in SRL. In CreateTPAFromText. CreateTPAFromText is only called in Players.scar, to initialize the Player's nick TPA. SRL uses it only for initialization. (As far as my quick grep could show anyway)
So unless some scripts use this extensively, this can't be the cause of the errors in SCAR.


Still should be freed. :3

i luffs yeww

2010-04-20 18:23:47

Happens (I've noticed) with ChooseOption, too, Wizzup. If you search for text before it's there it seems to happen (for me at least).

Nava2

2010-04-20 20:16:40

I think my choose option uses CreateTPAFromText….

tarajunky

2010-04-21 01:09:52

You're always welcome, Freddy. :)

mastaraymond

2010-04-21 02:45:11

From: Nava2
I think my choose option uses CreateTPAFromText….

Doubt it:


Search "CreateTPAFromText" (7 hits in 2 files)
C:\Remake\Includes\srl\SRL\core\Math.scar (6 hits)
Line 6: // * function CreateTPAFromText(Txt : string; Chars : string) : TPointArray; // * by Raymond
Line 7: // * function CreateTPAFromText(Txt : string; Chars : Integer) : TPointArray; // * by Raymond
Line 42: function CreateTPAFromText(Txt : string; Chars : string) : TPointArray;
Line 46: function CreateTPAFromText(Txt : string; Chars : string) : TPointArray;
Line 54: function CreateTPAFromText(Txt : string; Chars : Integer) : TPointArray;
Line 58: function CreateTPAFromText(Txt : string; Chars : Integer) : TPointArray;
C:\Remake\Includes\srl\SRL\core\Players.scar (1 hits)
Line 121: Players[I].NickTPA := CreateTPAFromText(Players[I].Nick, UpChars);

Everything else just uses

function LoadTextTPA(Text: string; Chars: Integer; var height: integer): TPointArray;
var
DC: HDC;
CTS, w, h :INteger;
BMP: Integer;
begin;
BMP := CreateBitmapMaskFromText(Text,Chars);
DC := GetClientCanvas.Handle;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(0);
GetBitmapSize(BMP,W,H);
SetTargetDc(GetBitmapDc(BMP));
FindColorsTolerance(Result,clwhite,0,0,w+1,h+1,0);
height := h - 1;
SetTargetDC(DC);
ColorToleranceSpeed(CTS);
FreeBitmap(BMP);
end;

Good find however, silly mistake on my side :$

WT-Fakawi

2010-04-21 04:32:55

Don't let personal grudges interfere with your place here, Freddy. Sure it is so we are working on our own macroing system, but really that shouldn't be an issue from a professional point of view.

But I understand nevertheless.

Home

2010-04-21 05:13:42

Thanks for pointing this out Fred, and like Fawki said, i think you have a place in here (: Even if Simba comes around, it doesn't change anything what you
have done for this community.

And it's not all about Scar and Simba. Heh :)

~Home

Wizzup?

2010-04-21 07:59:25

You're only as welcome as you want to be. It's entirely up to you. (If you don't act nice to people, they won't be nice to you either)
The choice you made not to come to SRL for awhile is entirely yours, and was not forced upon you.

I'm sorry I'm not being nicer ( :) ), but this isn't the first time you're saying everyone is against you… It annoys me that you constantly make yourself look like you're the innocent guy; like you're a victim of some conspiracy, which simply isn't the case.

weequ

2010-04-21 11:44:53

I get dib handle error when I use choose option and there has been something wrong with targetting the client… Sometimes (rarely) I also used to get it when handling with big TPoint arrays…(such as getting all colors from the array).

mastaraymond

2010-04-21 12:51:52

Yet you must admit that the open-sourceness of the plugin has helped you to find this bug, just saying.

Frement

2010-04-21 13:21:33

From: mastaraymond
Yet you must admit that the open-sourceness of the plugin has helped you to find this bug, just saying.


A bit offtopic but I just had an image in my head of you being "Ray William Johnson" because of the "just saying" :)

weequ

2010-04-21 16:27:18

I get dib handle error in this line:
FindColorsTolerance(TPA, 4016722, B.X1, B.Y1, B.X2, B.Y2, 0);
in text.scar… Actually i think there is something wrong with getclientdimensions :( as B.X2 and B.Y2 is declared with that…

And i just got these values for them before the error:
B.X2: 1244528
B.Y2: 2089870419

n3ss3s

2010-04-24 04:44:01


This is only called in one place in SRL. In CreateTPAFromText. CreateTPAFromText is only called in Players.scar, to initialize the Player's nick TPA. SRL uses it only for initialization. (As far as my quick grep could show anyway)
So unless some scripts use this extensively, this can't be the cause of the errors in SCAR.


causes me to jump into rageshoes and download kbot

I cant remember how did it exactly happen, but after doing some disabling/enabling of smart, restarting of script etc I had to move the crosshair onto smart to get me some coords, and if I did it like many times it gave that error right away…

SRL uses it only for initialization. (As far as my quick grep could show anyway)
And chooseoption which is only like the second most used function?

Gu3st...

2010-04-24 06:12:24

I have the same problem as antti mies..
There is a problem with GetClientDimensions
That's what causes it. I get the error every time I call GetMMLevels and GetClientDimensions is used in that function.
I get the error here:
FindColorsTolerance(P, Colors[i], SearchBox.x1,SearchBox.y1,SearchBox.x2,SearchBox.y2, 30);

Please fix this in scar-prerelease asap, Freddy! :)

Timer

2010-04-26 17:45:46

Something is just causing SCAR to lose focus on Runescape, that is what causes the numbers from GetClientDimensions

noidea

2010-04-26 17:58:55

From: Timer
Something is just causing SCAR to lose focus on Runescape, that is what causes the numbers from GetClientDimensions


Yea, well it still needs to be fixed to prevent SCAR from crashing and people loosing valuable work.

Timer

2010-04-26 18:36:51

From: noidea
Yea, well it still needs to be fixed to prevent SCAR from crashing and people loosing valuable work.


Who ever said it is scar?

Wizzup?

2010-04-26 18:39:54

From: Timer
Who ever said it is scar?


Well, if it occurs in rs_getUptext, what else can it be? GetClientDimensions returning rubbish surely isn't the scripters fault either.
IOW: Give your post some thought before you post…

Timer

2010-04-26 18:41:01

From: Wizzup?
Well, if it occurs in rs_getUptext, what else can it be? GetClientDimensions returning rubbish surely isn't the scripters fault either.
IOW: Give your post some thought before you post…


It could be LoadTextTPA :p

noidea

2010-04-26 21:03:54

From: Timer
It could be LoadTextTPA :p


I was specifically talking about getClientDimentions. The the hell could loadTextTPA affect that?????

Timer

2010-04-27 10:09:43

From: noidea
I was specifically talking about getClientDimentions. The the hell could loadTextTPA affect that?????


It messes with the client settings, switches DC, and etc.