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

Allocation profiling skip allocations #880

Closed
franz1981 opened this issue Jan 23, 2024 · 2 comments
Closed

Allocation profiling skip allocations #880

franz1981 opened this issue Jan 23, 2024 · 2 comments

Comments

@franz1981
Copy link

franz1981 commented Jan 23, 2024

Giving this reproducer

public class Alloc {

     private static volatile Object objs;	

     public static void main(String[] args) {
     	Object[] obj = new Object[1*1000*1000];
     	for (int i = 0; i < obj.length; i++) {
     	       obj[i] = new Object();
     	}
     	objs = obj;     	
     }
}

Before 6dfd215 if we run:

$ java  -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -XX:-UseTLAB -agentpath:<right path>/libasyncProfiler.so=start,event=alloc,file=alloc.html Alloc.java

it reported something like

image

which is both right in term of colors and magnitude (1_000_000 Object and 1 Object[]).
To be sure that I could see Object[] I have used the jfr format and extracted total, reporting

image

16_000_000 bytes for Object and 4_000_0016 bytes for Object[]

but after 6dfd215 it become

image

with 30 samples of Object and 1 sample for Object[].

I've used

java version "17.0.7" 2023-04-18 LTS
Java(TM) SE Runtime Environment (build 17.0.7+8-LTS-224)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.7+8-LTS-224, mixed mode, sharing)

Thanks @radcortez to have found it!

@apangin
Copy link
Collaborator

apangin commented Jan 23, 2024

That's by design.
The default allocation sampling interval is 512KB. If you want to count every allocation, set the sampling interval to 1:

java -XX:-UseTLAB -agentlib:asyncProfiler=start,alloc=1,total,file=alloc.html Alloc.java
alloc

@franz1981
Copy link
Author

Sorry @apangin I missed this change in behaviour!

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

No branches or pull requests

2 participants