lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Muir (JIRA)" <>
Subject [jira] [Commented] (LUCENE-4252) Detect/Fail tests when they leak RAM in static fields
Date Thu, 26 Jul 2012 00:34:34 GMT


Robert Muir commented on LUCENE-4252:

I looked at the patch but I didn't see where this idea went; perhaps I missed something. Anyway,
not important for now, I'll revisit after I'm back home.

Well unlike the first patch, it does no subtraction, it just counts the ram usage estimation
of all static fields. if they are null, this is of course 0. we don't really care where they
were created.

so now if i add this line to TestDemo:
static long huge[] = new long[2 * 1024 * 1024];

It fails like this:
[junit4:junit4] ERROR   0.00s | TestDemo (suite)
[junit4:junit4]    > Throwable #1: java.lang.RuntimeException: Please fix the static leaks
in your test in a @AfterClass, your test seems to hang on to approximately 16777232 bytes.
[junit4:junit4]    > 	at org.apache.lucene.util.TestRuleSetupAndRestoreClassEnv.after(

> Detect/Fail tests when they leak RAM in static fields
> -----------------------------------------------------
>                 Key: LUCENE-4252
>                 URL:
>             Project: Lucene - Core
>          Issue Type: Test
>          Components: general/test
>            Reporter: Robert Muir
>            Assignee: Dawid Weiss
>         Attachments: LUCENE-4252.patch, LUCENE-4252.patch
> We run our junit tests without firing up a JVM each time.
> But some tests initialize lots of stuff in @BeforeClass and don't properly null it out
in an @AfterClass, which can cause a subsequent test in the same JVM to OOM, which is difficult
to debug.
> Inspiration for this was me committing Mike's cool TestPostingsFormat, which forgot to
do this: then we were seeing OOMs in several jenkins runs.
> We should try to detect these leaks in LuceneTestCase with RAMUsageEstimator and fail
the test.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message