jbonofre commented on code in PR #1825:
URL: https://github.com/apache/activemq/pull/1825#discussion_r2989193233
##########
activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4930Test.java:
##########
@@ -110,17 +110,15 @@ public void doTestBrowsePending(int deliveryMode) throws
Exception {
LOG.info("Browsed: " + browsed.length);
assertEquals("maxBrowsePageSize", maxBrowsePageSize, browsed.length);
Runtime.getRuntime().gc();
- long free = Runtime.getRuntime().freeMemory()/1024;
- LOG.info("free at start of check: " + free);
+ long memoryUsageAtStart = underTest.getMemoryUsage().getUsage();
+ LOG.info("Memory usage at start of check: " + memoryUsageAtStart);
// check for memory growth
for (int i=0; i<10; i++) {
LOG.info("free: " + Runtime.getRuntime().freeMemory()/1024);
browsed = underTest.browse();
LOG.info("Browsed: " + browsed.length);
assertEquals("maxBrowsePageSize", maxBrowsePageSize,
browsed.length);
- Runtime.getRuntime().gc();
- Runtime.getRuntime().gc();
- assertTrue("No growth: " + Runtime.getRuntime().freeMemory()/1024
+ " >= " + (free - (free * 0.2)), Runtime.getRuntime().freeMemory()/1024 >=
(free - (free * 0.2)));
+ assertTrue("Memory usage is ballooning: " +
underTest.getMemoryUsage().getUsage() + " > " + memoryUsageAtStart,
underTest.getMemoryUsage().getUsage() <= memoryUsageAtStart);
Review Comment:
I think it's a bit strict here.
Currently the test has 20% tolerance.
Your overall approach is better: the broker memory accounting is more
deterministic than JVM free memory.
However, we can observe minor transient fluctuations.
I suggest to keep a tolerance margin here to avoid flakiness still:
```suggestion
assertTrue("Memory usage is ballooning: " +
underTest.getMemoryUsage().getUsage() + " > " + memoryUsageAtStart,
underTest.getMemoryUsage().getUsage() <= memoryUsageAtStart * 1.1);
```
##########
activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4930Test.java:
##########
@@ -110,17 +110,15 @@ public void doTestBrowsePending(int deliveryMode) throws
Exception {
LOG.info("Browsed: " + browsed.length);
assertEquals("maxBrowsePageSize", maxBrowsePageSize, browsed.length);
Runtime.getRuntime().gc();
- long free = Runtime.getRuntime().freeMemory()/1024;
- LOG.info("free at start of check: " + free);
+ long memoryUsageAtStart = underTest.getMemoryUsage().getUsage();
+ LOG.info("Memory usage at start of check: " + memoryUsageAtStart);
// check for memory growth
for (int i=0; i<10; i++) {
LOG.info("free: " + Runtime.getRuntime().freeMemory()/1024);
Review Comment:
Same here: as we are not using JVM free memory anymore, we can remove this
log message.
##########
activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4930Test.java:
##########
@@ -110,17 +110,15 @@ public void doTestBrowsePending(int deliveryMode) throws
Exception {
LOG.info("Browsed: " + browsed.length);
assertEquals("maxBrowsePageSize", maxBrowsePageSize, browsed.length);
Runtime.getRuntime().gc();
Review Comment:
As we are not using JVM free memory anymore, we can remove this `gc()` call.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact