Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not count size of referenced classes. #17

Closed
kamenik opened this issue Oct 31, 2014 · 2 comments
Closed

Do not count size of referenced classes. #17

kamenik opened this issue Oct 31, 2014 · 2 comments

Comments

@kamenik
Copy link

kamenik commented Oct 31, 2014

In case that instance contains reference to Class, MemoryMeter counts size of whole class to size of instance. Example:

for A B it says 16B, for C 16736B

import org.github.jamm.MemoryMeter;

public class Test {

public static void main(final String[] args) throws InterruptedException {
    MemoryMeter mm = new MemoryMeter();
    System.out.println(mm.measureDeep(new A()));
    System.out.println(mm.measureDeep(new B()));
    System.out.println(mm.measureDeep(new C()));
}

static class A {}

static class B {
    Class<B> c;
}

static class C {
    Class<C> c = C.class;
}

}

@mebigfatguy
Copy link
Collaborator

Added the option (in trunk) to exclude the recursive size calculations of known singletons, which currently are Class objects, and Enums. use new MemoryMeter().ignoreKnownSingletons();

@mebigfatguy
Copy link
Collaborator

commit be724a3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants