Is there a way to get a list of object types in object set via API?
In dotMemory it is possible to list all types that are contained in an object set.
In dotMemory Unit, the ObjectSet class provides getters for 'ObjectsCount' and 'SizeInBytes', but (as far as I know!?) it is not possible to get a list of all types that are contained in an object set.
---
var firstSnapshot = dotMemory.Check();
//do something
dotMemory.Check(memory =>
{
var newObjects = memory.GetDifference(firstSnapshot).GetNewObjects();
var subSet = newObjects.GetObjects(x => x.Namespace.Like("MyNamespace.*"));
Console.WriteLine("Number of objects: " + subSet.ObjectsCount);
Console.WriteLine("Size in bytes: " + subSet.SizeInBytes);
var subSetObjectsList = subSet.ToList()); //not available
...
});
---
Is there any possibility to get all types of objects that are contained in a set? If not, might there be a method in future versions?
Such a method would be great for some automated tests, for example:
1. make first snapshot
2. call some function
3. make another snapshot and save list of new objects since first snapshot (type, size in bytes and number of objects)
4. do n times:
4a. call function
4b. make snapshot and save list of new objects since last snapshot (type, size in bytes and number of objects)
5. for all types in the lists, do some checks on collected data (e.g.: is number of objects of any type growing faster than linear?)
6. if a check fails, save .dmw file with all snapshots
Best regards,
Lukas
Please sign in to leave a comment.
Hi Lukas, thanks for your question.
As you mentioned dotMemory Unit provides only two numbers because according to our idea it is designed for unit tests, where asserts on some already known state are usually used. What you are describing is more similar to an "automatic inspection" like in standalone dotMemory isn't it? (dotMemory Unit also provides access to them.) Do you have some other needs like that which is not implemented in dotMemory Unit?
Back to the question we can implement it in dotMemory Unit like
IObjectSet.GroupByType() : IEnumerable<{TypeName, ObjectsCount, Size}>
will it suit your needs?
Hi Lukas,
you can track the progress of the feature here https://youtrack.jetbrains.com/issue/DMU-191
Hi Ed,
thank you for your fast reply!
IObjectSet.GroupByType() : IEnumerable<{TypeName, ObjectsCount, Size}>
would be great! This method will make dotMemory Unit even more powerful and could definitely be used to implement the example I provided in the initial posting.
As you said, dotMemory Unit is great for assertions on already known states. A method that allows iterating over all types contained in an object set, like 'GroupByType' as you described it, allows using dotMemory Unit also to ascertain memory issues on not well known states.
Thanks!