Memory Recovery 
Author Message
 Memory Recovery

I have a VB6 app that I am concerned about running out of memory.
The user can list an unlimited number of path\filenames for documents.
If memory runs out loading a control or an array, I would expect an out of
memory error to be thrown.

So my question is.
Upon error trapping,    does VB6 crash or keep enough reserves to allow a
successful continuation, say after I delete to stop loading the control or
array?

Or is there a better way to handle this user input situation?

This is limit difficult to determine since it will depend on the PC RAM and
what other app are running.  Correct?



Sun, 11 Mar 2012 00:18:38 GMT  
 Memory Recovery


Quote:
> I have a VB6 app that I am concerned about running out of memory.
> The user can list an unlimited number of path\filenames for documents.
> If memory runs out loading a control or an array, I would expect an out of
> memory error to be thrown.

> So my question is.
> Upon error trapping,    does VB6 crash or keep enough reserves to allow a
> successful continuation, say after I delete to stop loading the control or
> array?

> Or is there a better way to handle this user input situation?

> This is limit difficult to determine since it will depend on the PC RAM
and
> what other app are running.  Correct?

First off, note that an Application or box seldom runs out of "memory", they
do however often run out of "resources" (GDIs, handles, etc.) - the
exception of course is when you start dedicating blocks of memory greater
than the O/S can service.

So normally with an adequate amount of Error checking you can catch one of
these conditions, BUT the problem is "can the application continue". If you
have run out of resources - then probably not unless you can somehow "roll
back". If the problem occurs off in some component (or chain of components),
or if you have run out of a fundamental resource, there may be little your
application can do - but try to exit gracefully.

Second, while for some basic resources one can make an assumption going in
about what is likely "too much", for example trying to open a mega-gig file,
or having a zillion owner-drawn controls, in the real world - when an
application starts to push on the edges of the envelope - problems almost
always seem to come from something or somewhere unexpected. So it is not
impossible to determine the limit before-hand but usually ends up being
merely a good guess. (Bound to fail somewhere. <g>)

At some level the requirement of "unlimited number" is ill-logical. After
all any system has limits. Try to get a handle on what "unlimited" really
means. I find it difficult to imagine how a user would supply such a
number - he is going to click on a couple of folders, or worse multi-select
a ton of files? ie, simply gathering up an "unlimited number' is going to be
a chore. Dump from a database?

In that case, you might simply let the user supply the folder, database,
etc., and then your app can go mine them at its leisure.

When faced with a requirement to manage a huge mass of stuff it is always
best to break it up into chunks. Then your app can manage a chunk, clean
itself up, go grab the next chunk etc. If the next chunk is too much - then
fall back to the last chunk. Also consider - do you even need an unlimited
number of something at one time. ie, what are you planning to do with it?
While chunky is better than chatty, perhaps you can actually massage each
path/file as it comes in. If not to a completed task - at least to some
reduced product.

hth
-ralph



Sun, 11 Mar 2012 01:11:41 GMT  
 Memory Recovery

Quote:

> This is limit difficult to determine since it will depend on the PC RAM and
> what other app are running.  Correct?

Just adding to what Ralph already offered.  The direct answer to this question is,
"No."  All Win32 apps have a 2GB address space by default.  It's possible to extend
that to 3GB, but that's a topic for another day, and it's safe to just stick with
the 2GB default for the sake of understanding your problem.  That number is
unrelated to physical RAM installed in the PC.  Period.  You *must* work within that
constraint, which could mean re-examining your algorithms as Ralph suggests.  It's
really as simple as that.
--
.NET: It's About Trust!
 http://vfred.mvps.org


Sun, 11 Mar 2012 01:27:11 GMT  
 Memory Recovery

Quote:
> First off, note that an Application or box seldom runs out of "memory",
> they
> do however often run out of "resources" (GDIs, handles, etc.) - the

XP has a limit of 10,000 GDI objects, and I ran into that limit few
times(outside of VB, running about 20-30 apps or IE windows). Some message
boxes or windows don't appear as expected when this happens. Here is a link
that covers it:

http://en.wikipedia.org/wiki/Graphics_Device_Interface#Limitations

Quote: "Windows 95, 98, and Millennium had a limit of 1,200 total objects;
Windows 2000 has a limit of 16,384 objects; and Windows XP, Vista, and
Windows 7 have a configurable limit (via the registry) that defaults to
10,000 objects."



Sun, 11 Mar 2012 01:33:09 GMT  
 Memory Recovery
I get that.
But when a one user has a PC with 4G and could use all 2G (maybe) and
another user has XP with 500MBytes then limiting to 500M (sort of) seems sort
of unfair to the 2G user.
Am I confused?
Quote:

> I have a VB6 app that I am concerned about running out of memory.
> The user can list an unlimited number of path\filenames for documents.
> If memory runs out loading a control or an array, I would expect an out of
> memory error to be thrown.

> So my question is.
> Upon error trapping,    does VB6 crash or keep enough reserves to allow a
> successful continuation, say after I delete to stop loading the control or
> array?

> Or is there a better way to handle this user input situation?

> This is limit difficult to determine since it will depend on the PC RAM and
> what other app are running.  Correct?



Sun, 11 Mar 2012 07:43:03 GMT  
 Memory Recovery

Quote:

> I get that.
> But when a one user has a PC with 4G and could use all 2G (maybe) and
> another user has XP with 500MBytes then limiting to 500M (sort of) seems sort
> of unfair to the 2G user.
> Am I confused?

Yes.  Windows gives each 32-bit process 2GB of address space, *regardless* of how
much physical memory the machine may have.  (Say that over and over until you
believe it! <g>)

That said, "limiting" your process's memory consumption to 500Mb would be the
courteous thing to do, regardless of what sort of hardware you find yourself on.
--
.NET: It's About Trust!
 http://vfred.mvps.org



Sun, 11 Mar 2012 07:48:31 GMT  
 Memory Recovery


Quote:
> I have a VB6 app that I am concerned about running out of memory.
> The user can list an unlimited number of path\filenames for documents.
> If memory runs out loading a control or an array, I would expect an
> out of memory error to be thrown.

> So my question is.
> Upon error trapping,    does VB6 crash or keep enough reserves to
> allow a successful continuation, say after I delete to stop loading
> the control or array?

> Or is there a better way to handle this user input situation?

> This is limit difficult to determine since it will depend on the PC
> RAM and what other app are running.  Correct?

Do some testing. How are these items displayed ? Listview ? Treeview ?
*ONLY* an array ?

A string array, with a MAX_PATH of 260, each being the max length,
1,000,000 entries would be approx 264 megs of RAM usage.

That would be the ONLY thing I would ever think of that could possibly,
or should I say would be coded, to do.

Loading even 50K items into a Listview or Treeview, or Listbox (max 32K
?), or any control would take so long that you would **never** want to
code it that way, and user would b*tch and complain more than you could
imagine. Possibly a virtual listview with a database recordset or array
behind it, but a VB listview ?!?!?!? No way.

Are you maybe over thinking this ? (Not always a bad thing.)



Sun, 11 Mar 2012 08:06:37 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Memory, Memory and more Memory

2. Recovery of Access Database

3. How recovery deleted records in mdb(97')?

4. MDB access recovery Germany- need link.

5. Accidental Cascade Delete: Data Recovery Procedures, please

6. Please help -- urgent MDB recovery problem

7. Access possword recovery?

8. Excel 200 password recovery

9. Programatically deleting items from recovery folder???

10. Global.mpt recovery

11. DocumentBeforeSave Event and auto recovery files

12. Document Recovery

 

 
Powered by phpBB® Forum Software