Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

EOutOfResources

14 views
Skip to first unread message

peter i

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to
i am not sure if this belongs in this group or not, but i was wondering
if anyone has any clues as to why i sometimes get an EOutOfResources
exception and what i can do to prevent it from happening... thanks in
advance...


Andrue Cope

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to
Peter,

> has any clues as to why i sometimes get an EOutOfResources
> exception
>

You get it because you have consumed too many resources and the OS
has no more to give.

> what i can do to prevent it from happening...
>

Don't be so greedy :)
If you are autocreating your forms - stop it! Create and destroy your
forms on demand as in the following example:

bool FormGoto_Show( TRegionSupport_Region *RegionList,
DWORD &BlockNumber,
DWORD LastBlockNumber )
{
std::auto_ptr<TfrmGoto>frmGoto( new TfrmGoto( NULL ) );

if( frmGoto->Setup( RegionList,
BlockNumber,
LastBlockNumber ) )
{
if( frmGoto->ShowModal()==mrOk )
return frmGoto->GetBlockNumber( BlockNumber );
}

return false;
}

Or if you aren't familiar with std::auto_ptr

bool FormGoto_Show( TRegionSupport_Region *RegionList,
DWORD &BlockNumber,
DWORD LastBlockNumber )
{
TfrmGoto *frmGoto=new TfrmGoto( NULL );

try
{
if( frmGoto->Setup( RegionList,
BlockNumber,
LastBlockNumber ) )
{
if( frmGoto->ShowModal()==mrOk )
return frmGoto->GetBlockNumber( BlockNumber );
}

return false;
}
__finally
{
delete frmGoto;
frmGoto=NULL; // Not really needed but a good habit IMHO.
}
}

Andrue Cope
[Bicester, UK]


peter i

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to
>
> You get it because you have consumed too many resources and the OS
> has no more to give.
>

what kind of resources?

>
> > what i can do to prevent it from happening...
> >
>
> Don't be so greedy :)
>
> If you are autocreating your forms - stop it! Create and destroy your
> forms on demand as in the following example:
>

i have only one form in my application. i have a few linked lists but i
clean them up entirely (memory sleuth says that i have no unreleased
resources and i c hecked it a few hundred times already.)


Andrue Cope

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to
Peter,

Think of the exception as the computer equivalent of a letter from your
Bank Manager telling you that you have reached the limit of your
overdraft. Now think of your last reply to me as a request to help you
sort out your finances.

The problem (for me) in both cases is the same - I don't have enough
information.

I can make a few general suggestions but they all boil down to "reduce
your resource consumption" in the same way as I might say "stop spending
so much money". Neither is a particularly helpful comment but without
working alongside you on your project it's unlikely that I can offer much
more specific help.

> i have only one form in my application.
>

Are there lots of components on it?

> (memory sleuth says
>

I haven't used Memory Sleuth myself but if it's any good I would expect it
to be able to tell you what has been allocated and what source line
allocated it.

Andrue Cope
[Bicester, UK]


peter i

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to
> Think of the exception as the computer equivalent of a letter from your
> Bank Manager telling you that you have reached the limit of your
> overdraft. Now think of your last reply to me as a request to help you
> sort out your finances.

interesting analogy....


> The problem (for me) in both cases is the same - I don't have enough
> information.
>

me either...i don't know what kinds of things take up resources or what the
different kinds of resources are. is there a limit to the number of pointers
that i can have living at any one time? how big is the stack? are there
tools to le me know how much of a particular resource type i am taking up and
what it is that is taking it up?

>
> > i have only one form in my application.
> >
>
> Are there lots of components on it?
>

a few but now many. it is multi threaded and the threads don't live as
components on the form but rather they are manually typed in units. i am
working on a thread that is running out of resources when it runs....

> > (memory sleuth says
> >
>
> I haven't used Memory Sleuth myself but if it's any good I would expect it
> to be able to tell you what has been allocated and what source line
> allocated it.
>

well it really only tells you what has been leaking. i think.


Andrue Cope

unread,
Jul 19, 2000, 3:00:00 AM7/19/00
to
Peter,

> what the different kinds of resources are.
>

Ah, sorry I hadn't realised. 'Resources' in this context are those
specifically used by the Windows operating system. As the help
states:

EOutOfResources is thrown when an application attempts to create a
Windows handle and Windows has no more handles to allocate.

So it's Windows telling you that /it/ can't give you what you the
handle based resource that you want. This can be influenced by the
memory or stack that your program consumes but when they grow too
large you will be told using a different exception. It's also worth
knowing that resources are a system wide issue - other applications
cause Windows to consume them as well.

If you are running under Win9x then this may just mean you've got too
many other applications loaded. It might be your application which
triggered the exception but maybe you're just the final straw that
brakes the camel's back <s>.

What OS are you running? If it's Win9x then I'm not too surprised
since it has definite limits on resources. If it's WinNT then
something funny is going on.

Andrue Cope
[Bicester, UK]


J.A. Bijsterbosch

unread,
Jul 19, 2000, 3:00:00 AM7/19/00
to
Hello Peter,

peter i <situ...@yahoo.com> schreef in berichtnieuws
39747887...@yahoo.com...


> >
> > You get it because you have consumed too many resources and the OS
> > has no more to give.
>
> what kind of resources?

Hmm, you don't have done something like:
Image->Picture->Bitmap->HandleType = bmDIB;

I did that just a few days ago and although the Image wasn't used yet, I
immediately got an EOutOfResources error... Why this happened I don't know
though.

--
Greetings from overcast Amsterdam

Jan

email: bij...@worldonline.nl
http://home.worldonline.nl/~bijster

peter i

unread,
Jul 19, 2000, 3:00:00 AM7/19/00
to
>
> Ah, sorry I hadn't realised. 'Resources' in this context are those

no problem...thanks for understanding.

> specifically used by the Windows operating system. As the help
> states:
>
> EOutOfResources is thrown when an application attempts to create a
> Windows handle and Windows has no more handles to allocate.
>

i was thinking that something like that was the issue...but i was not
sure.

>
> So it's Windows telling you that /it/ can't give you what you the
> handle based resource that you want. This can be influenced by the
> memory or stack that your program consumes but when they grow too
> large you will be told using a different exception. It's also worth
> knowing that resources are a system wide issue - other applications
> cause Windows to consume them as well.
>
> If you are running under Win9x then this may just mean you've got too
> many other applications loaded. It might be your application which

hmmm...i close everything that shows up in the list when you do
ctrl-alt-del except for explorer the system tray and the mouse driver

> triggered the exception but maybe you're just the final straw that
> brakes the camel's back <s>.
>
> What OS are you running? If it's Win9x then I'm not too surprised
> since it has definite limits on resources. If it's WinNT then
>

it is win98...so how can i control this? is there some way for me to be
able to test for resource utilization before trying something and then
freeing up something to avoid the exception? is there anyway for me to
know what resources are in use and by whom and/or what line of code in my
program saked for the resource?

> something funny is going on.

will try it under nt. thanks.


peter i

unread,
Jul 19, 2000, 3:00:00 AM7/19/00
to

"J.A. Bijsterbosch" wrote:

> Hello Peter,
>
> peter i <situ...@yahoo.com> schreef in berichtnieuws
> 39747887...@yahoo.com...
> > >
> > > You get it because you have consumed too many resources and the OS
> > > has no more to give.
> >
> > what kind of resources?
>
> Hmm, you don't have done something like:
> Image->Picture->Bitmap->HandleType = bmDIB;
>

no not explicitly, but i am manipulating bitmaps (adding them to graphs,
saving graphs as bitmaps, converting bitmaps to jpgs...) with pre-made
components...could it be related?

Andrue Cope

unread,
Jul 20, 2000, 3:00:00 AM7/20/00
to
Peter,

> it is win98...so how can i control this? is there some way for me to be
> able to test for resource utilization before trying something and then
> freeing up something to avoid the exception?
>

Given that you have closed everything else down it /should/ only be
happening if you have a lot of forms (or a few forms with a lot of
components) or are generally "making free" with Graphical components.

If the visual side of your project is pretty simple this shouldn't be an
issue but I note from another of your replies that you are maniuplating
bitmaps. This is the kind of thing that could easily consume resources if
they are screen sized or if a lot of maniuplation is going on.

Andrue Cope
[Bicester, UK]


peter i

unread,
Jul 20, 2000, 3:00:00 AM7/20/00
to

Andrue Cope wrote:

> Peter,
>
> > it is win98...so how can i control this? is there some way for me to be
> > able to test for resource utilization before trying something and then
> > freeing up something to avoid the exception?
> >
>
> Given that you have closed everything else down it /should/ only be
> happening if you have a lot of forms (or a few forms with a lot of
> components) or are generally "making free" with Graphical components.
>

making free?

>
> If the visual side of your project is pretty simple this shouldn't be an
> issue but I note from another of your replies that you are maniuplating
> bitmaps. This is the kind of thing that could easily consume resources if
> they are screen sized or if a lot of maniuplation is going on.
>

the bitmaps are not screen size...in fact they are never actually shown on
screen at all. they exist in memory only while being manipulated, as are all
the objects that i am using when running this thread. other thread teps of
this program don't have this problem,....what i am doing is assigning a bitmap
to the background of a TChart. then saving the whole chart as a bitmap. then
converting the bitmap to a jpg. all dtors are being called so i am not
exactly sure what the problem is....

thanks.


Andrue Cope

unread,
Jul 21, 2000, 3:00:00 AM7/21/00
to
Peter,

> making free?
>

Sorry again <s>. I used an everyday English phrase which perhaps was confusing
in this context or may not be international. It means "using as if there were
no restrictions".

> in fact they are never actually shown on
> screen at all. they exist in memory only while being manipulated, as are all
> the objects that i am using when running this thread
>

It doesn't matter much where they are. If they are being manipulated by Windows
then they are consuming Windows resources since it has to keep track of them.

Andrue Cope
[Bicester, UK]


peter i

unread,
Jul 24, 2000, 3:00:00 AM7/24/00
to
> > in fact they are never actually shown on
> > screen at all. they exist in memory only while being manipulated, as are all
> > the objects that i am using when running this thread
> >
>
> It doesn't matter much where they are. If they are being manipulated by Windows
> then they are consuming Windows resources since it has to keep track of them.
>

could it be that the dtors are not properly releasing GDI resources then? is there
another possibility?

>
> Andrue Cope
> [Bicester, UK]


Andrue Cope

unread,
Jul 24, 2000, 3:00:00 AM7/24/00
to
Peter,

> could it be that the dtors are not properly releasing GDI resources then?
>

That would almost certainly cause the problem.

Andrue Cope
[Bicester, UK]


J.A. Bijsterbosch

unread,
Jul 24, 2000, 3:00:00 AM7/24/00
to
Hello peter,

peter i <situ...@yahoo.com> schreef in berichtnieuws

397603AB...@yahoo.com...


>
> > Hmm, you don't have done something like:
> > Image->Picture->Bitmap->HandleType = bmDIB;
>
> no not explicitly, but i am manipulating bitmaps (adding them to graphs,
> saving graphs as bitmaps, converting bitmaps to jpgs...) with pre-made
> components...could it be related?

Well, I couldn't say<g>, but getting stuck with to few resources is
something of W9x where there is a limited amount. There are a lot of
possibilities to get you into trouble. Excessive Bitmap sizes (e.g.
3000x2500 or bigger afaik), not correctly deleting or freeing what's not
used anymore, etc.

The above was my own error btw. One needs a Handle first before you can set
the HandleType it seems<g>...

0 new messages