lidavidm commented on code in PR #35314:
URL: https://github.com/apache/arrow/pull/35314#discussion_r1175905492
##########
java/memory/memory-netty/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java:
##########
@@ -1091,6 +1098,40 @@ public void testMemoryLeakWithReservation() throws
Exception {
}
}
+ @Test
+ public void testMemoryUsage() {
+ MemoryLogsAppender memoryLogsAppender = new MemoryLogsAppender();
+ Logger logger = (Logger) LoggerFactory.getLogger("arrow.allocator");
+ logger.setLevel(Level.TRACE);
+ logger.addAppender(memoryLogsAppender);
+ memoryLogsAppender.start();
+
+ try (ArrowBuf buf = new ArrowBuf(ReferenceManager.NO_OP, null,
+ 1024, new PooledByteBufAllocatorL().empty.memoryAddress())) {
+ buf.memoryAddress();
+ }
+
+ boolean contains = memoryLogsAppender
+ .contains(
+ Arrays.asList("Memory Usage: \n", "Large buffers outstanding: ",
"Normal buffers outstanding: "),
+ Level.TRACE
+ );
+
+ assertTrue(contains);
+ }
+
+ class MemoryLogsAppender extends ListAppender<ILoggingEvent> {
+ public boolean contains(List<String> values, Level level) {
+ return list.stream()
Review Comment:
Just inline this? I don't see why we need a subclass and a method
##########
java/memory/memory-netty/src/main/java/io/netty/buffer/PooledByteBufAllocatorL.java:
##########
@@ -265,7 +265,7 @@ public MemoryStatusThread() {
@Override
public void run() {
while (true) {
- memoryLogger.trace("Memory Usage: \n{}",
PooledByteBufAllocatorL.this.toString());
+ memoryLogger.trace("Memory Usage: \n{}",
PooledByteBufAllocatorL.this.allocator);
Review Comment:
Since this is a background thread, doesn't the test need to account for a
potential race condition?
##########
java/memory/memory-netty/src/test/java/org/apache/arrow/memory/TestBaseAllocator.java:
##########
@@ -1091,6 +1098,40 @@ public void testMemoryLeakWithReservation() throws
Exception {
}
}
+ @Test
+ public void testMemoryUsage() {
+ MemoryLogsAppender memoryLogsAppender = new MemoryLogsAppender();
+ Logger logger = (Logger) LoggerFactory.getLogger("arrow.allocator");
+ logger.setLevel(Level.TRACE);
+ logger.addAppender(memoryLogsAppender);
+ memoryLogsAppender.start();
Review Comment:
This test will permanently add an appender to a global logger, can we remove
the appender afterwards?
--
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]