Reduce memory consumption
See original GitHub issueWe observed increased memory usage in our microservices, after applying micrometer. Heap dumps showed that a lot of memory is consumed by histograms stored in our timers. Following is an extract from such dump:
io.micrometer.core.instrument.step.StepTimer@0xf97e62a0
- histogram: TimeWindowLatencyHistogram@0xf97e6398
- accumulatedHistogram: Histogram@0xf982e7a0
- counts: [long]@0xf982e9f0 (10256 bytes)
- ringBuffer: [LatencyStats]
0: LatencyStats@0xf9821a50
- activePauseCorrectionsHistogram: Histogram@0xf98299f0
- counts: [long]@0xf9829c40 (10256 bytes)
- activeRecordingHistogram: AtomicHistogram@0xf9826f70
- counts: AtomicHistogram@0xf98271d0
- array: [long]@0xf98271e0 (10256 bytes)
- inactivePauseCorrectionsHistogram: Histogram@0xf9824510
- counts: [long]@0xf9824760 (10256 bytes)
- inactiveRawDataHistogram: AtomicHistogram@0xf9821a90
- counts: AtomicHistogram@0xf9821cf0
- array: [long]@0xf9821d00 (10256 bytes)
- intervalEstimator: TimeCappedMovingAverageIntervalEstimator@0xf982c4c8
- intervalEndTimes: [long]@0xf982c518 (8208 bytes)
And there is 4 more LatencyStats objects in that ringBuffer array.
Summing only long arrays: 10256 + (10256 * 4) * 5 = 215376 bytes Total for all 80 timers that we have: 215376 * 80 = 16.4 mb
We don’t use histograms and percentiles, so we’ve overcame the problem with custom implementation of the Timer interface. But it would be great to have a better solution straight in the Micrometer.
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (10 by maintainers)
Top Results From Across the Web
How to Free Up RAM and Reduce RAM Usage on Windows
1. Restart Your PC · 2. Check RAM Usage With Windows Tools · 3. Uninstall or Disable Unneeded Software · 4. Update Your...
Read more >How to Reduce Memory Usage - Techwalla
Close windows and exit programs when you are done using them. Having many unnecessary programs and windows open wastes RAM. If your computer...
Read more >Reducing RAM usage - Untangle Support
Reducing RAM usage · Disable and uninstall memory-intensive applications. · Uninstall disabled applications. · Uninstall applications that are running but have no ...
Read more >10+ Ways to Free up RAM On Your Windows or Mac Device
5 Ways to Free up RAM on Windows 10 · 1. Track Memory and Clean Up Processes · 2. Disable Startup Programs You...
Read more >11 ways to decrease RAM usage and speed up your computer
11 ways to reduce your RAM usage · Turn your device off and on · Check which programs are draining your RAM ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After decreasing buffer length to 3, adding a new configuration option for digits of precision used in computing percentile approximations, and adding new histogram implementations that are more memory efficient when you don’t need client-side percentiles, we have this result.
1 digit of precision seems to be satisfactory for percentile approximations ±5% of true value. 3 digits of precision yields ±0.1%, but at a much higher memory cost.
@jkschneider thanks!