diff --git a/ddprof-lib/src/main/cpp/flightRecorder.cpp b/ddprof-lib/src/main/cpp/flightRecorder.cpp index 08ae4b709..6d7b07b70 100644 --- a/ddprof-lib/src/main/cpp/flightRecorder.cpp +++ b/ddprof-lib/src/main/cpp/flightRecorder.cpp @@ -903,9 +903,9 @@ void Recording::writeJvmInfo(Buffer *buf) { buf->putVar64(_start_ticks); buf->putUtf8(jvm_name); buf->putUtf8(jvm_version); - buf->putUtf8(_jvm_args); - buf->putUtf8(_jvm_flags); - buf->putUtf8(_java_command); + buf->putUtf8(_jvm_args != nullptr ? _jvm_args : ""); + buf->putUtf8(_jvm_flags != nullptr ? _jvm_flags : ""); + buf->putUtf8(_java_command != nullptr ? _java_command : ""); buf->putVar64(OS::processStartTime()); buf->putVar64(OS::processId()); buf->putVar32(start, buf->offset() - start); diff --git a/ddprof-test/src/test/java/com/datadoghq/profiler/jfr/ObjectSampleDumpSmokeTest.java b/ddprof-test/src/test/java/com/datadoghq/profiler/jfr/ObjectSampleDumpSmokeTest.java index 15837706f..9cc1df596 100644 --- a/ddprof-test/src/test/java/com/datadoghq/profiler/jfr/ObjectSampleDumpSmokeTest.java +++ b/ddprof-test/src/test/java/com/datadoghq/profiler/jfr/ObjectSampleDumpSmokeTest.java @@ -15,11 +15,11 @@ protected boolean isPlatformSupported() { @Override protected String getProfilerCommand() { - return "memory=1024:a"; + return "memory=128:a"; } @RetryingTest(5) - @Timeout(value = 60) + @Timeout(value = 300) public void test() throws Exception { runTest("datadog.ObjectSample", "method3"); } diff --git a/ddprof-test/src/test/java/com/datadoghq/profiler/memleak/GCGenerationsTest.java b/ddprof-test/src/test/java/com/datadoghq/profiler/memleak/GCGenerationsTest.java index 2e9870382..092a5ad45 100644 --- a/ddprof-test/src/test/java/com/datadoghq/profiler/memleak/GCGenerationsTest.java +++ b/ddprof-test/src/test/java/com/datadoghq/profiler/memleak/GCGenerationsTest.java @@ -20,7 +20,7 @@ public class GCGenerationsTest extends AbstractProfilerTest { @Override protected String getProfilerCommand() { - return "generations=true,cstack=fp"; + return "memory=128,generations=true,cstack=fp"; } @Override @@ -28,29 +28,12 @@ protected boolean isPlatformSupported() { return !(Platform.isJavaVersion(8) || Platform.isJ9() || Platform.isZing()); } - @RetryingTest(5) + @RetryingTest(10) public void shouldGetLiveObjectSamples() throws InterruptedException { MemLeakTarget target1 = new MemLeakTarget(); MemLeakTarget target2 = new MemLeakTarget(); runTests(target1, target2); - IItemCollection allocations = verifyEvents("datadog.HeapLiveObject"); - -// assertAllocations(allocations, int[].class, target1, target2); -// assertAllocations(allocations, Integer[].class, target1, target2); - } - - private static void assertAllocations(IItemCollection allocations, Class clazz, MemLeakTarget... targets) { - long allocated = 0; - for (MemLeakTarget target : targets) { - allocated += target.getAllocated(clazz); - } - IItemCollection allocationsByType = allocations.apply(allocatedTypeFilter(clazz.getCanonicalName())); - assertTrue(allocationsByType.hasItems()); - long recorded = allocationsByType.getAggregate(Aggregators.sum(SCALED_SIZE)).longValue(); - long absoluteError = Math.abs(recorded - allocated); - assertTrue(absoluteError < allocated / 10, - String.format("allocation samples should be within 10pct tolerance of allocated memory (recorded %d, allocated %d)", - recorded, allocated)); + verifyEvents("datadog.HeapLiveObject"); } public static class MemLeakTarget extends ClassValue implements Runnable { @@ -89,10 +72,11 @@ private static void allocate(ThreadLocalRandom random, int depth) { obj = new Integer[random.nextInt(64, 192) * 1000]; } - if (random.nextInt(100) == 0 && sink.size() < 100_000) { + if (random.nextInt(100) <= 30 && sink.size() < 100_000) { sink.add(obj); } if (random.nextInt(10000) == 0) { + System.out.println("Triggering GC"); System.gc(); } } diff --git a/ddprof-test/src/test/java/com/datadoghq/profiler/settings/DatadogSettingsTest.java b/ddprof-test/src/test/java/com/datadoghq/profiler/settings/DatadogSettingsTest.java index c07cf67dc..ac3064eff 100644 --- a/ddprof-test/src/test/java/com/datadoghq/profiler/settings/DatadogSettingsTest.java +++ b/ddprof-test/src/test/java/com/datadoghq/profiler/settings/DatadogSettingsTest.java @@ -2,6 +2,7 @@ import com.datadoghq.profiler.AbstractProfilerTest; import org.junit.jupiter.api.Test; +import org.junitpioneer.jupiter.RetryingTest; import org.openjdk.jmc.common.item.IAttribute; import org.openjdk.jmc.common.item.IItem; import org.openjdk.jmc.common.item.IItemCollection; @@ -21,7 +22,7 @@ protected String getProfilerCommand() { return "cpu=1ms"; } - @Test + @RetryingTest(5) public void testRecordDatadogSetting() { profiler.recordSetting("dimensionless", "value"); profiler.recordSetting("withUnit", "60", "seconds");