Re: Tips on finding memory leaks
- From: "Ralph" <nt_consulting64@xxxxxxxxx>
- Date: Wed, 19 Dec 2007 12:58:04 -0600
"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:u5QFktcQIHA.1208@xxxxxxxxxxxxxxxxxxxxxxx
Does anybody have any tips on finding memory leaks in VB code,particularly
in conjunction with ADO? I've got a data tier which seems to be more thana
bit leaky, and I'm not entirely sure where the problem lies. It'seven
particularly hard to pinpoint, given that I know ADO caches data and so
forth, so I'm never entirely sure when to expect all my memory to be
returned and when not.
I know the obvious one of de-referencing objects, and I'll certainly look
for those, but beyond that, I'm not sure what else to look for. I suspect
some of the reference problems may be hidden in collection classes that're
allocating space of child objects, but not properly de-allocating them,
when the parent class itself is shut down, but I'm not sure how to goabout
proving that or rectifying it.VB,
Any suggestions, either specific to ADO, collections, or just general to
would be appreciated.
Here is one article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;248014
[Ghod, I miss Soft-ICE. <g>]
As for tracing memory leaks with VB, I have no good advice. If you were
using VC++ then you have a few more tools to both peek and play. The main
trouble with VB is it doesn't matter where the problem is occurring as you
will likely need to re-architect your code to get rid of it. That is, it is
seldom a spot-fix. As VB is too far removed from the source. (The universal
problem with a RAD tool.)
The other issue is simply the number of actors in any one scenario. First
there is your code, then ADO, then the connection Pool, then the Provider,
then the database engine.
As for your code - you mentioned "collection classes". VB's Collection is
not the best performing creature around. Anytime you are abusing them to any
extent I suggest you look around for one the many substitutes available on
the web.
As far as releasing memory goes, VB Collection objects while darn slow, are
very deterministic, i.e.. the memory will get released. So I wouldn't waste
time over that - with the single exception of Collections that contain
objects that contains references to other objects. You obviously have to be
very careful that everyone cleans up after themselves. If you have done
that, then the Collection will do its job.
For critical situations I have found that just about the only way to narrow
it down is to create various simplified Test Beds, and test, change, test,
change, test, .. <g>
Something else I will throw out to you even though I know you well enough to
believe you are already aware of this. I only bring it up because you
mentioned collections and child objects along with ADO. Often when designing
an OO front-end for a relational database, we need to mine the data and then
build an object model - which always leads us into impedance-mismatch
problems.
For example, reading in a bunch of recordsets and using them to construct a
Object Model that is a collection of child objects, when that is exactly
what a Recordset is: "A collection of collections contains objects". Often
it is simplier to rework the query (or even the data store) to retrieve a
Recordset which can then be wrapped with an object to provide the same
information and ease of access that building an object Collection can - and
usually at far less expense. e.g., let it factory-build child objects on
demand, and destroy when no longer needed.
The other reason I mention it is because usually when we run into "memory
problems" - it isn't memory that is the problem - its because we have made
too many demands on it and have reached the edge of the envelope and
probably should look at another way to get the same results. Not every ideal
object model scales well. <g>
hth
-ralph
.
- Follow-Ups:
- Re: Tips on finding memory leaks
- From: Robert Morley
- Re: Tips on finding memory leaks
- From: Robert Morley
- Re: Tips on finding memory leaks
- References:
- Tips on finding memory leaks
- From: Robert Morley
- Tips on finding memory leaks
- Prev by Date: Re: Print preview image in a picture box
- Next by Date: Re: Tips on finding memory leaks
- Previous by thread: Re: Tips on finding memory leaks
- Next by thread: Re: Tips on finding memory leaks
- Index(es):
Relevant Pages
|