From d76a1d026cca39b24e7b07a909294ef520cb86ef Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Thu, 18 Apr 2024 09:28:16 +0200 Subject: [PATCH] LDEV-4833 build: log memory usage with a GC --- test/run-tests.cfm | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/test/run-tests.cfm b/test/run-tests.cfm index b68fd749be..3ea37897c6 100644 --- a/test/run-tests.cfm +++ b/test/run-tests.cfm @@ -150,7 +150,12 @@ try { var rpt = replace(ucFirst(qry.type), '_', ' ') & " " & qry.name & ": " & numberFormat(perc) & "%, " & numberFormat( qry.used / 1024 / 1024 ) & " Mb"; if ( structKeyExists( arguments.prev, qry.name ) ) { - rpt &= ", (+ " & numberFormat( (qry.used - arguments.prev[ qry.name ] ) / 1024 / 1024 ) & " Mb)"; + var change = numberFormat( (qry.used - arguments.prev[ qry.name ] ) / 1024 / 1024 ); + if ( change gt 0 ) { + rpt &= ", (+ " & change & "Mb )"; + } else if ( change lt 0 ) { + rpt &= ", ( " & change & "Mb )"; + } } arrayAppend( report, rpt ); used[ qry.name ] = qry.used; @@ -373,8 +378,24 @@ try { arrayAppend( results, "Active Threads: #NumberFormat( threadCount )#"); arrayAppend( results, "CFTHREADS: #NumberFormat( ThreadData().len() )#"); + postTestMeM = reportMem( "", _reportMemStat.usage ); + arrayAppend( results, postTestMeM.report, true ); + arrayAppend( results, "Force GC"); + createObject( "java", "java.lang.System" ).gc(); + + postTestGC = reportMem( "", postTestMeM.usage ) + arrayAppend( results, ""); + arrayAppend( results, postTestGC.report, true ); + + structClear( CFTHREAD ); arrayAppend( results, ""); - arrayAppend( results, reportMem( "", _reportMemStat.usage ).report, true ); + arrayAppend( results, "Force GC after structClear(cfthread)"); + createObject( "java", "java.lang.System" ).gc(); + arrayAppend( results, "CFTHREADS: #NumberFormat( ThreadData().len() )#"); + arrayAppend( results, "Active Threads: #NumberFormat( threadCount )#"); + arrayAppend( results, ""); + arrayAppend( results, reportMem( "", postTestGC.usage ).report, true ); + arrayAppend( results, ""); arrayAppend( results, "=============================================================" & NL); arrayAppend( results, "-> Bundles/Suites/Specs: #result.getTotalBundles()#/#result.getTotalSuites()#/#result.getTotalSpecs()#");