[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[mat-dev] Viewing Discarded Objects
|
Memory Analyzer has
the facility to copy with huge heaps (>2^31 objects) or more than the
heap can manage by discarding objects.
This can be useful,
does reduce the number of objects, but the object graph is modified, and
even if the leak can be spotted it is harder to understand because some
of the strings giving names of objects might have been discarded.
I have a work-around
for the latter problem. Generally MAT using an int index to represent an
object. However, once you have an IObject you can find its address. You
can read fields (and array entries using "[13]" etc.) and call
getOutboundReferences(). These return a ObjectReference object, which could
represent an unindexed (discarded) object as it holds the object ID, the
address and the snapshot.
I didn't want
to change the API as this is still experimental. There isn't a way of getting
unindexed objects by address from directly from a snapshot, or from a parser
via IHeapObjectReader
Currently
int
objectId
= snapshot.mapAddressToId(address);
IObject object =
snapshot.getObject(objectId);
instead I suggest
the following:
ObjectReference
ref = new ObjectReference(snapshot,
address);
IObject object =
ref.getObject()
I also wanted
the inspector view to show unindexed objects and fields of those objects
and to be able to inspect those fields and go into them.
I also wanted
some support for OQL.
To get this to
work I need a way for the parser to construct this new object.
https://help.eclipse.org/2021-03/topic/org.eclipse.mat.ui.help/doc/org/eclipse/mat/parser/IObjectReader.html
To
construct this object my idea is that the parser needs to provide a getAddon
for ObjectReference, returning a parser specific version. The parser can
then override getObject and retrieve an object at the address which has
been inserted into the object. So the base ObjectReference tries to get
the object ID and call snapshot.getObject(). If there is no object ID,
then it constructs a proxy ObjectReference from the parser, inserts the
required object address, and lets the parser return the object.
I
have made the changes - but there is still some time to improve or revert
them so give it a try with snapshots with discarded objects.
--
Andrew
Johnson
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number
741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6
3AU