[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

VB6: How to pre-empt out-of-memory error?

(Mike Mitchell)

5/10/2012 2:58:00 PM

I'm adding reams of data to a ListView, whereupon, inevitably, at some
point an out-of-memory error occurs. I'd like to pre-empt the error
and warn the user that an OOM error is likely very shortly, and thus
give the user a chance to abandon the current procedure.

To that end I copied the code at
http://www.vbforums.com/showthread.ph...

into a new VB6 project. This returns:

Total Physical Memory: 2,031,088K
Available Physical Memory: 1,219,952K
Percentage Memory In Use: 39%
Maximum Paging File Size: 2,563, 192K
Kilobytes Available In Paging File: 1,870,416K
Total Virtual Memory: 2,097,024K
Available Virtual Memory: 2,015,524K

(Above values on a Windows 2000 PC)

I would assume that it's the Percentage Memory In Use value (39% in
the above example) that I need to watch and warn the user if it
reaches, say, 80%

Is this correct to assume so, or should I be watching one of the other
values instead or as well?

MM
6 Answers

Dee Earley

5/10/2012 3:38:00 PM

0

On 10/05/2012 15:57, MM wrote:
> I'm adding reams of data to a ListView, whereupon, inevitably, at some
> point an out-of-memory error occurs. I'd like to pre-empt the error
> and warn the user that an OOM error is likely very shortly, and thus
> give the user a chance to abandon the current procedure.
<SNIP>
> Is this correct to assume so, or should I be watching one of the other
> values instead or as well?

No, there can be many things that it could run out of at any point that
you can't easily check for
Handles, GDI objects, windows, control limits, Memory that's been paged
out, etc.

Your best bet is just to handle the situation when it occurs.

Don't forget that the act of checking a condition may trigger that
condition, and you may always end up with a race condition.

--
Deanna Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk...

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

Karl E. Peterson

5/10/2012 4:05:00 PM

0

MM laid this down on his screen :
> I'm adding reams of data to a ListView, whereupon, inevitably, at some
> point an out-of-memory error occurs. I'd like to pre-empt the error
> and warn the user that an OOM error is likely very shortly, and thus
> give the user a chance to abandon the current procedure.

OOM rarely refers to actual memory. It's the catch-all error phrase
chosen for when no other more closely fits.

If you're blowing up a LV, I'd recommend looking into virtual LVs (or
grids) instead.

--
..NET: It's About Trust!
http://vfre...


(Mike Mitchell)

5/10/2012 4:39:00 PM

0

On Thu, 10 May 2012 09:05:23 -0700, Karl E. Peterson <karl@exmvps.org>
wrote:

>MM laid this down on his screen :
>> I'm adding reams of data to a ListView, whereupon, inevitably, at some
>> point an out-of-memory error occurs. I'd like to pre-empt the error
>> and warn the user that an OOM error is likely very shortly, and thus
>> give the user a chance to abandon the current procedure.
>
>OOM rarely refers to actual memory. It's the catch-all error phrase
>chosen for when no other more closely fits.
>
>If you're blowing up a LV, I'd recommend looking into virtual LVs (or
>grids) instead.

Okay. I'm going to work up a paging scheme instead.

MM

(Mike Mitchell)

5/11/2012 8:50:00 AM

0

On Thu, 10 May 2012 17:38:48 +0100, MM <kylix_is@yahoo.co.uk> wrote:

>On Thu, 10 May 2012 09:05:23 -0700, Karl E. Peterson <karl@exmvps.org>
>wrote:
>
>>MM laid this down on his screen :
>>> I'm adding reams of data to a ListView, whereupon, inevitably, at some
>>> point an out-of-memory error occurs. I'd like to pre-empt the error
>>> and warn the user that an OOM error is likely very shortly, and thus
>>> give the user a chance to abandon the current procedure.
>>
>>OOM rarely refers to actual memory. It's the catch-all error phrase
>>chosen for when no other more closely fits.
>>
>>If you're blowing up a LV, I'd recommend looking into virtual LVs (or
>>grids) instead.
>
>Okay. I'm going to work up a paging scheme instead.
>
>MM

Turned out to be a doddle. Whacked a VideoSoft FlexGrid on the form
instead of ListView, set VirtualData to True (default, anyway),
whacked in an ADO recordset to DataSource. Job done!

MM

Mike Williams

5/11/2012 9:41:00 AM

0

"MM" <kylix_is@yahoo.co.uk> wrote in message
news:sgkpq755v13qn2hc721h3phjqan8cdnpn5@4ax.com...
>
> Turned out to be a doddle. Whacked a VideoSoft FlexGrid
> on the form instead of ListView, set VirtualData to True
> (default, anyway), whacked in an ADO recordset to
> DataSource. Job done!

http://www.youtube.com/watch?v=G...

Mike


Karl E. Peterson

5/11/2012 4:27:00 PM

0

MM wrote on 5/11/2012 :
> On Thu, 10 May 2012 17:38:48 +0100, MM <kylix_is@yahoo.co.uk> wrote:
>
>> On Thu, 10 May 2012 09:05:23 -0700, Karl E. Peterson <karl@exmvps.org>
>> wrote:
>>
>>> MM laid this down on his screen :
>>>> I'm adding reams of data to a ListView, whereupon, inevitably, at some
>>>> point an out-of-memory error occurs. I'd like to pre-empt the error
>>>> and warn the user that an OOM error is likely very shortly, and thus
>>>> give the user a chance to abandon the current procedure.
>>>
>>> OOM rarely refers to actual memory. It's the catch-all error phrase
>>> chosen for when no other more closely fits.
>>>
>>> If you're blowing up a LV, I'd recommend looking into virtual LVs (or
>>> grids) instead.
>>
>> Okay. I'm going to work up a paging scheme instead.
>
> Turned out to be a doddle. Whacked a VideoSoft FlexGrid on the form
> instead of ListView, set VirtualData to True (default, anyway),
> whacked in an ADO recordset to DataSource. Job done!

There ya go! :-)

--
..NET: It's About Trust!
http://vfre...