You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Clebert Suconic <cl...@gmail.com> on 2023/07/10 18:13:34 UTC

Surefire leaking ClassMethod

We have recently upgraded surefire into artemis  from 2.x, and
strangely our testsuite started to crash because of memory.


So, it happens that I had other memory leaks in the past and I became
addicted into finding them, up to a point that I created a project
that will track memory usage over a java app, or be used on test cases
to make sure leaks are not happening:


https://github.com/check-leak/check-leak


So,


I ran this testsuite from artemis:

git clone git@github.com:apache/activemq-artemis.git
cd activemq-artemis
mvn install -DskipTests=true
cd tests/integration-tests
mvn -Ptests tests



get check-leak:
curl https://github.com/check-leak/check-leak/releases/download/0.11/check-leak-0.11.jar

so after finding the process ID for the surefire:
java -jar check-leak-0.11.jar --sleep 5000 --pid <surefire-pid>
--report ./report-leak



As the test progress, open ./report-leak/index.html


you may refresh the page as the process go.


and if you look at the objects  allocations for
org.apache.maven.surefire.api.util.internal.ClassMethod, the
allocations are only growing after the lates version, and never being
released.




is there any idea about what might be causing it?


if you have a big project with many tests like I do, memory
allocations may be an issue and I would need to use a bigger VM just
because of this probably leak.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire leaking ClassMethod

Posted by Clebert Suconic <cl...@gmail.com>.
just for the record I just opened a dev thread about this.

On Wed, Jul 12, 2023 at 9:31 AM Clebert Suconic
<cl...@gmail.com> wrote:
>
> Also.. is there a MavenLauncher on surefire-its or anywhere else that
> will run multiple tests?
>
> On Wed, Jul 12, 2023 at 9:28 AM Clebert Suconic
> <cl...@gmail.com> wrote:
> >
> > it seems there is surefire-its for integration tests and there are a
> > couple of resources it will use.
> >
> > I think I should create a new module, surefire-leaktests using
> > check-leak to validate for leaks and use the launcher to run a small
> > testsuite and validate the leaks at the end.
> >
> > One challenge I have is how to get access to MavenLauncher from the
> > new module, and I would need a test-dependency for that.
> >
> > Would you guys see the test dependency on surefire-leaktests a
> > deterrent for a merge?
> >
> >
> >
> > BTW: This thread is becoming a dev thread (as I'm slowly moving from
> > user to dev myself :) )... but if we could keep this thread as it
> > would have the whole context... it would be great..
> > however if there is a bigger crowd more focused  on the dev list just
> > say the word and I will start a thread to the Maven Dev List.
> >
> > On Tue, Jul 11, 2023 at 7:22 PM Tamás Cservenák <ta...@cservenak.net> wrote:
> > >
> > > Yes, leak test are warmly welcome :)
> > >
> > > T
> > >
> > > On Wed, Jul 12, 2023, 01:17 Enrico Olivelli <eo...@gmail.com> wrote:
> > >
> > > > Il Mer 12 Lug 2023, 00:15 Clebert Suconic <cl...@gmail.com> ha
> > > > scritto:
> > > >
> > > > > On Tue, Jul 11, 2023 at 6:13 PM Clebert Suconic
> > > > > <cl...@gmail.com> wrote:
> > > > > >
> > > > > > How tests are simulated within maven-surefire? is there any example?
> > > > >
> > > > > I mean... a test testing the test! Something that will call surefire
> > > > > and its unit tests and validate outcome?
> > > > >
> > > >
> > > > There are many integration tests in the surefire repository.
> > > > Initially it is not straightforward to understand but it works.
> > > > Unfortunately it passed some time since I wrote tests for surefire.
> > > >
> > > > I hope that others in this list my help
> > > >
> > > > Enrico
> > > >
> > > > >
> > > > > >
> > > > > > Would I be able to create an optional module where I do a test-leak
> > > > > > using my library to validate if it leaked or not?
> > > > > >
> > > > > > On Tue, Jul 11, 2023 at 5:33 PM Clebert Suconic
> > > > > > <cl...@gmail.com> wrote:
> > > > > > >
> > > > > > > I tried looking at how I would contribute a fix, but I lacked an
> > > > > > > understanding on how tests are performed in surefire.
> > > > > > >
> > > > > > > Also: would you accept a test that's using check-leak to prevent
> > > > > > > future leaks like this? (maybe a separate sub-module for this
> > > > > > > test?)... and where I would add such test?
> > > > > > >
> > > > > > > I would even dedicate my personal time into proposing a fix if I can
> > > > > > > get some basic understanding about this.
> > > > > > >
> > > > > > >
> > > > > > > Is there a chat channel I can ask questions about the codebase? or
> > > > the
> > > > > > > user's or dev's list is a good place to start?
> > > > > > >
> > > > > > > On Tue, Jul 11, 2023 at 5:24 PM Enrico Olivelli <eolivelli@gmail.com
> > > > >
> > > > > wrote:
> > > > > > > >
> > > > > > > > Clebert,
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Il Mar 11 Lug 2023, 15:55 Clebert Suconic <
> > > > clebert.suconic@gmail.com>
> > > > > ha
> > > > > > > > scritto:
> > > > > > > >
> > > > > > > > > created a JIRA:
> > > > > > > > >
> > > > > > > > > https://issues.apache.org/jira/browse/SUREFIRE-2186
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Thanks.
> > > > > > > > Would you have time to contribute a fix?
> > > > > > > >
> > > > > > > > Enrico
> > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > On Tue, Jul 11, 2023 at 9:33 AM Clebert Suconic
> > > > > > > > > <cl...@gmail.com> wrote:
> > > > > > > > > >
> > > > > > > > > > You guys need to be careful with non static ThreadLocals.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > ClassMethodIndexer has a non static ThreadLocal.
> > > > > > > > > >
> > > > > > > > > > threadLocals will create a hashEntry somewhere deep in the JDK.
> > > > > > > > > > Depending on the number of tests that are running you guys may
> > > > > break
> > > > > > > > > > things like ReadWriteLock because it will transverse a lot of
> > > > > entries.
> > > > > > > > > > (I have been bitten by this before).
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Also, I have a reproducer:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > git clone
> > > > > https://github.com/clebertsuconic/surefire-reproducer.git
> > > > > > > > > > cd surefire-reproducer
> > > > > > > > > > mvn install
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > This little project is using check-leak to count the number of
> > > > > > > > > > instances of ClassObject. I have set the assertions as max 20
> > > > > > > > > > instances. I have a copy&paste test that is validating this
> > > > over
> > > > > and
> > > > > > > > > > over.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > And it's always leaking inside a ConcurrentHashMap that's being
> > > > > held
> > > > > > > > > > by ClassMethodIndex which is used by JUnit4Listener.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > and you guys should really stop using non static ThreadLocals..
> > > > > I have
> > > > > > > > > > found another case where it was used but at least the remove
> > > > was
> > > > > > > > > > called.. but still a bit scary to my test (It should just use a
> > > > > static
> > > > > > > > > > final... what's the point of a ThreadLocal if it's not static
> > > > on
> > > > > a
> > > > > > > > > > class an associated to the instance?)
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Should I open a JIRA about this?
> > > > > > > > > >
> > > > > > > > > > On Mon, Jul 10, 2023 at 2:13 PM Clebert Suconic
> > > > > > > > > > <cl...@gmail.com> wrote:
> > > > > > > > > > >
> > > > > > > > > > > We have recently upgraded surefire into artemis  from 2.x,
> > > > and
> > > > > > > > > > > strangely our testsuite started to crash because of memory.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > So, it happens that I had other memory leaks in the past and
> > > > I
> > > > > became
> > > > > > > > > > > addicted into finding them, up to a point that I created a
> > > > > project
> > > > > > > > > > > that will track memory usage over a java app, or be used on
> > > > > test cases
> > > > > > > > > > > to make sure leaks are not happening:
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > https://github.com/check-leak/check-leak
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > So,
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I ran this testsuite from artemis:
> > > > > > > > > > >
> > > > > > > > > > > git clone git@github.com:apache/activemq-artemis.git
> > > > > > > > > > > cd activemq-artemis
> > > > > > > > > > > mvn install -DskipTests=true
> > > > > > > > > > > cd tests/integration-tests
> > > > > > > > > > > mvn -Ptests tests
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > get check-leak:
> > > > > > > > > > > curl
> > > > > > > > >
> > > > >
> > > > https://github.com/check-leak/check-leak/releases/download/0.11/check-leak-0.11.jar
> > > > > > > > > > >
> > > > > > > > > > > so after finding the process ID for the surefire:
> > > > > > > > > > > java -jar check-leak-0.11.jar --sleep 5000 --pid
> > > > <surefire-pid>
> > > > > > > > > > > --report ./report-leak
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > As the test progress, open ./report-leak/index.html
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > you may refresh the page as the process go.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > and if you look at the objects  allocations for
> > > > > > > > > > > org.apache.maven.surefire.api.util.internal.ClassMethod, the
> > > > > > > > > > > allocations are only growing after the lates version, and
> > > > > never being
> > > > > > > > > > > released.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > is there any idea about what might be causing it?
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > if you have a big project with many tests like I do, memory
> > > > > > > > > > > allocations may be an issue and I would need to use a bigger
> > > > > VM just
> > > > > > > > > > > because of this probably leak.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Clebert Suconic
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Clebert Suconic
> > > > > > > > >
> > > > > > > > >
> > > > > ---------------------------------------------------------------------
> > > > > > > > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > > > > > > > For additional commands, e-mail: users-help@maven.apache.org
> > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Clebert Suconic
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Clebert Suconic
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Clebert Suconic
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > > > For additional commands, e-mail: users-help@maven.apache.org
> > > > >
> > > > >
> > > >
> >
> >
> >
> > --
> > Clebert Suconic
>
>
>
> --
> Clebert Suconic



-- 
Clebert Suconic

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire leaking ClassMethod

Posted by Clebert Suconic <cl...@gmail.com>.
Also.. is there a MavenLauncher on surefire-its or anywhere else that
will run multiple tests?

On Wed, Jul 12, 2023 at 9:28 AM Clebert Suconic
<cl...@gmail.com> wrote:
>
> it seems there is surefire-its for integration tests and there are a
> couple of resources it will use.
>
> I think I should create a new module, surefire-leaktests using
> check-leak to validate for leaks and use the launcher to run a small
> testsuite and validate the leaks at the end.
>
> One challenge I have is how to get access to MavenLauncher from the
> new module, and I would need a test-dependency for that.
>
> Would you guys see the test dependency on surefire-leaktests a
> deterrent for a merge?
>
>
>
> BTW: This thread is becoming a dev thread (as I'm slowly moving from
> user to dev myself :) )... but if we could keep this thread as it
> would have the whole context... it would be great..
> however if there is a bigger crowd more focused  on the dev list just
> say the word and I will start a thread to the Maven Dev List.
>
> On Tue, Jul 11, 2023 at 7:22 PM Tamás Cservenák <ta...@cservenak.net> wrote:
> >
> > Yes, leak test are warmly welcome :)
> >
> > T
> >
> > On Wed, Jul 12, 2023, 01:17 Enrico Olivelli <eo...@gmail.com> wrote:
> >
> > > Il Mer 12 Lug 2023, 00:15 Clebert Suconic <cl...@gmail.com> ha
> > > scritto:
> > >
> > > > On Tue, Jul 11, 2023 at 6:13 PM Clebert Suconic
> > > > <cl...@gmail.com> wrote:
> > > > >
> > > > > How tests are simulated within maven-surefire? is there any example?
> > > >
> > > > I mean... a test testing the test! Something that will call surefire
> > > > and its unit tests and validate outcome?
> > > >
> > >
> > > There are many integration tests in the surefire repository.
> > > Initially it is not straightforward to understand but it works.
> > > Unfortunately it passed some time since I wrote tests for surefire.
> > >
> > > I hope that others in this list my help
> > >
> > > Enrico
> > >
> > > >
> > > > >
> > > > > Would I be able to create an optional module where I do a test-leak
> > > > > using my library to validate if it leaked or not?
> > > > >
> > > > > On Tue, Jul 11, 2023 at 5:33 PM Clebert Suconic
> > > > > <cl...@gmail.com> wrote:
> > > > > >
> > > > > > I tried looking at how I would contribute a fix, but I lacked an
> > > > > > understanding on how tests are performed in surefire.
> > > > > >
> > > > > > Also: would you accept a test that's using check-leak to prevent
> > > > > > future leaks like this? (maybe a separate sub-module for this
> > > > > > test?)... and where I would add such test?
> > > > > >
> > > > > > I would even dedicate my personal time into proposing a fix if I can
> > > > > > get some basic understanding about this.
> > > > > >
> > > > > >
> > > > > > Is there a chat channel I can ask questions about the codebase? or
> > > the
> > > > > > user's or dev's list is a good place to start?
> > > > > >
> > > > > > On Tue, Jul 11, 2023 at 5:24 PM Enrico Olivelli <eolivelli@gmail.com
> > > >
> > > > wrote:
> > > > > > >
> > > > > > > Clebert,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Il Mar 11 Lug 2023, 15:55 Clebert Suconic <
> > > clebert.suconic@gmail.com>
> > > > ha
> > > > > > > scritto:
> > > > > > >
> > > > > > > > created a JIRA:
> > > > > > > >
> > > > > > > > https://issues.apache.org/jira/browse/SUREFIRE-2186
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Thanks.
> > > > > > > Would you have time to contribute a fix?
> > > > > > >
> > > > > > > Enrico
> > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > On Tue, Jul 11, 2023 at 9:33 AM Clebert Suconic
> > > > > > > > <cl...@gmail.com> wrote:
> > > > > > > > >
> > > > > > > > > You guys need to be careful with non static ThreadLocals.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > ClassMethodIndexer has a non static ThreadLocal.
> > > > > > > > >
> > > > > > > > > threadLocals will create a hashEntry somewhere deep in the JDK.
> > > > > > > > > Depending on the number of tests that are running you guys may
> > > > break
> > > > > > > > > things like ReadWriteLock because it will transverse a lot of
> > > > entries.
> > > > > > > > > (I have been bitten by this before).
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Also, I have a reproducer:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > git clone
> > > > https://github.com/clebertsuconic/surefire-reproducer.git
> > > > > > > > > cd surefire-reproducer
> > > > > > > > > mvn install
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > This little project is using check-leak to count the number of
> > > > > > > > > instances of ClassObject. I have set the assertions as max 20
> > > > > > > > > instances. I have a copy&paste test that is validating this
> > > over
> > > > and
> > > > > > > > > over.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > And it's always leaking inside a ConcurrentHashMap that's being
> > > > held
> > > > > > > > > by ClassMethodIndex which is used by JUnit4Listener.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > and you guys should really stop using non static ThreadLocals..
> > > > I have
> > > > > > > > > found another case where it was used but at least the remove
> > > was
> > > > > > > > > called.. but still a bit scary to my test (It should just use a
> > > > static
> > > > > > > > > final... what's the point of a ThreadLocal if it's not static
> > > on
> > > > a
> > > > > > > > > class an associated to the instance?)
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Should I open a JIRA about this?
> > > > > > > > >
> > > > > > > > > On Mon, Jul 10, 2023 at 2:13 PM Clebert Suconic
> > > > > > > > > <cl...@gmail.com> wrote:
> > > > > > > > > >
> > > > > > > > > > We have recently upgraded surefire into artemis  from 2.x,
> > > and
> > > > > > > > > > strangely our testsuite started to crash because of memory.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > So, it happens that I had other memory leaks in the past and
> > > I
> > > > became
> > > > > > > > > > addicted into finding them, up to a point that I created a
> > > > project
> > > > > > > > > > that will track memory usage over a java app, or be used on
> > > > test cases
> > > > > > > > > > to make sure leaks are not happening:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > https://github.com/check-leak/check-leak
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > So,
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I ran this testsuite from artemis:
> > > > > > > > > >
> > > > > > > > > > git clone git@github.com:apache/activemq-artemis.git
> > > > > > > > > > cd activemq-artemis
> > > > > > > > > > mvn install -DskipTests=true
> > > > > > > > > > cd tests/integration-tests
> > > > > > > > > > mvn -Ptests tests
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > get check-leak:
> > > > > > > > > > curl
> > > > > > > >
> > > >
> > > https://github.com/check-leak/check-leak/releases/download/0.11/check-leak-0.11.jar
> > > > > > > > > >
> > > > > > > > > > so after finding the process ID for the surefire:
> > > > > > > > > > java -jar check-leak-0.11.jar --sleep 5000 --pid
> > > <surefire-pid>
> > > > > > > > > > --report ./report-leak
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > As the test progress, open ./report-leak/index.html
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > you may refresh the page as the process go.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > and if you look at the objects  allocations for
> > > > > > > > > > org.apache.maven.surefire.api.util.internal.ClassMethod, the
> > > > > > > > > > allocations are only growing after the lates version, and
> > > > never being
> > > > > > > > > > released.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > is there any idea about what might be causing it?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > if you have a big project with many tests like I do, memory
> > > > > > > > > > allocations may be an issue and I would need to use a bigger
> > > > VM just
> > > > > > > > > > because of this probably leak.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Clebert Suconic
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Clebert Suconic
> > > > > > > >
> > > > > > > >
> > > > ---------------------------------------------------------------------
> > > > > > > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > > > > > > For additional commands, e-mail: users-help@maven.apache.org
> > > > > > > >
> > > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Clebert Suconic
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Clebert Suconic
> > > >
> > > >
> > > >
> > > > --
> > > > Clebert Suconic
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > > For additional commands, e-mail: users-help@maven.apache.org
> > > >
> > > >
> > >
>
>
>
> --
> Clebert Suconic



-- 
Clebert Suconic

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire leaking ClassMethod

Posted by Clebert Suconic <cl...@gmail.com>.
it seems there is surefire-its for integration tests and there are a
couple of resources it will use.

I think I should create a new module, surefire-leaktests using
check-leak to validate for leaks and use the launcher to run a small
testsuite and validate the leaks at the end.

One challenge I have is how to get access to MavenLauncher from the
new module, and I would need a test-dependency for that.

Would you guys see the test dependency on surefire-leaktests a
deterrent for a merge?



BTW: This thread is becoming a dev thread (as I'm slowly moving from
user to dev myself :) )... but if we could keep this thread as it
would have the whole context... it would be great..
however if there is a bigger crowd more focused  on the dev list just
say the word and I will start a thread to the Maven Dev List.

On Tue, Jul 11, 2023 at 7:22 PM Tamás Cservenák <ta...@cservenak.net> wrote:
>
> Yes, leak test are warmly welcome :)
>
> T
>
> On Wed, Jul 12, 2023, 01:17 Enrico Olivelli <eo...@gmail.com> wrote:
>
> > Il Mer 12 Lug 2023, 00:15 Clebert Suconic <cl...@gmail.com> ha
> > scritto:
> >
> > > On Tue, Jul 11, 2023 at 6:13 PM Clebert Suconic
> > > <cl...@gmail.com> wrote:
> > > >
> > > > How tests are simulated within maven-surefire? is there any example?
> > >
> > > I mean... a test testing the test! Something that will call surefire
> > > and its unit tests and validate outcome?
> > >
> >
> > There are many integration tests in the surefire repository.
> > Initially it is not straightforward to understand but it works.
> > Unfortunately it passed some time since I wrote tests for surefire.
> >
> > I hope that others in this list my help
> >
> > Enrico
> >
> > >
> > > >
> > > > Would I be able to create an optional module where I do a test-leak
> > > > using my library to validate if it leaked or not?
> > > >
> > > > On Tue, Jul 11, 2023 at 5:33 PM Clebert Suconic
> > > > <cl...@gmail.com> wrote:
> > > > >
> > > > > I tried looking at how I would contribute a fix, but I lacked an
> > > > > understanding on how tests are performed in surefire.
> > > > >
> > > > > Also: would you accept a test that's using check-leak to prevent
> > > > > future leaks like this? (maybe a separate sub-module for this
> > > > > test?)... and where I would add such test?
> > > > >
> > > > > I would even dedicate my personal time into proposing a fix if I can
> > > > > get some basic understanding about this.
> > > > >
> > > > >
> > > > > Is there a chat channel I can ask questions about the codebase? or
> > the
> > > > > user's or dev's list is a good place to start?
> > > > >
> > > > > On Tue, Jul 11, 2023 at 5:24 PM Enrico Olivelli <eolivelli@gmail.com
> > >
> > > wrote:
> > > > > >
> > > > > > Clebert,
> > > > > >
> > > > > >
> > > > > >
> > > > > > Il Mar 11 Lug 2023, 15:55 Clebert Suconic <
> > clebert.suconic@gmail.com>
> > > ha
> > > > > > scritto:
> > > > > >
> > > > > > > created a JIRA:
> > > > > > >
> > > > > > > https://issues.apache.org/jira/browse/SUREFIRE-2186
> > > > > >
> > > > > >
> > > > > >
> > > > > > Thanks.
> > > > > > Would you have time to contribute a fix?
> > > > > >
> > > > > > Enrico
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > > On Tue, Jul 11, 2023 at 9:33 AM Clebert Suconic
> > > > > > > <cl...@gmail.com> wrote:
> > > > > > > >
> > > > > > > > You guys need to be careful with non static ThreadLocals.
> > > > > > > >
> > > > > > > >
> > > > > > > > ClassMethodIndexer has a non static ThreadLocal.
> > > > > > > >
> > > > > > > > threadLocals will create a hashEntry somewhere deep in the JDK.
> > > > > > > > Depending on the number of tests that are running you guys may
> > > break
> > > > > > > > things like ReadWriteLock because it will transverse a lot of
> > > entries.
> > > > > > > > (I have been bitten by this before).
> > > > > > > >
> > > > > > > >
> > > > > > > > Also, I have a reproducer:
> > > > > > > >
> > > > > > > >
> > > > > > > > git clone
> > > https://github.com/clebertsuconic/surefire-reproducer.git
> > > > > > > > cd surefire-reproducer
> > > > > > > > mvn install
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > This little project is using check-leak to count the number of
> > > > > > > > instances of ClassObject. I have set the assertions as max 20
> > > > > > > > instances. I have a copy&paste test that is validating this
> > over
> > > and
> > > > > > > > over.
> > > > > > > >
> > > > > > > >
> > > > > > > > And it's always leaking inside a ConcurrentHashMap that's being
> > > held
> > > > > > > > by ClassMethodIndex which is used by JUnit4Listener.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > and you guys should really stop using non static ThreadLocals..
> > > I have
> > > > > > > > found another case where it was used but at least the remove
> > was
> > > > > > > > called.. but still a bit scary to my test (It should just use a
> > > static
> > > > > > > > final... what's the point of a ThreadLocal if it's not static
> > on
> > > a
> > > > > > > > class an associated to the instance?)
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Should I open a JIRA about this?
> > > > > > > >
> > > > > > > > On Mon, Jul 10, 2023 at 2:13 PM Clebert Suconic
> > > > > > > > <cl...@gmail.com> wrote:
> > > > > > > > >
> > > > > > > > > We have recently upgraded surefire into artemis  from 2.x,
> > and
> > > > > > > > > strangely our testsuite started to crash because of memory.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > So, it happens that I had other memory leaks in the past and
> > I
> > > became
> > > > > > > > > addicted into finding them, up to a point that I created a
> > > project
> > > > > > > > > that will track memory usage over a java app, or be used on
> > > test cases
> > > > > > > > > to make sure leaks are not happening:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > https://github.com/check-leak/check-leak
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > So,
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I ran this testsuite from artemis:
> > > > > > > > >
> > > > > > > > > git clone git@github.com:apache/activemq-artemis.git
> > > > > > > > > cd activemq-artemis
> > > > > > > > > mvn install -DskipTests=true
> > > > > > > > > cd tests/integration-tests
> > > > > > > > > mvn -Ptests tests
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > get check-leak:
> > > > > > > > > curl
> > > > > > >
> > >
> > https://github.com/check-leak/check-leak/releases/download/0.11/check-leak-0.11.jar
> > > > > > > > >
> > > > > > > > > so after finding the process ID for the surefire:
> > > > > > > > > java -jar check-leak-0.11.jar --sleep 5000 --pid
> > <surefire-pid>
> > > > > > > > > --report ./report-leak
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > As the test progress, open ./report-leak/index.html
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > you may refresh the page as the process go.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > and if you look at the objects  allocations for
> > > > > > > > > org.apache.maven.surefire.api.util.internal.ClassMethod, the
> > > > > > > > > allocations are only growing after the lates version, and
> > > never being
> > > > > > > > > released.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > is there any idea about what might be causing it?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > if you have a big project with many tests like I do, memory
> > > > > > > > > allocations may be an issue and I would need to use a bigger
> > > VM just
> > > > > > > > > because of this probably leak.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Clebert Suconic
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Clebert Suconic
> > > > > > >
> > > > > > >
> > > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > > > > > For additional commands, e-mail: users-help@maven.apache.org
> > > > > > >
> > > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Clebert Suconic
> > > >
> > > >
> > > >
> > > > --
> > > > Clebert Suconic
> > >
> > >
> > >
> > > --
> > > Clebert Suconic
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
> >



-- 
Clebert Suconic

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire leaking ClassMethod

Posted by Tamás Cservenák <ta...@cservenak.net>.
Yes, leak test are warmly welcome :)

T

On Wed, Jul 12, 2023, 01:17 Enrico Olivelli <eo...@gmail.com> wrote:

> Il Mer 12 Lug 2023, 00:15 Clebert Suconic <cl...@gmail.com> ha
> scritto:
>
> > On Tue, Jul 11, 2023 at 6:13 PM Clebert Suconic
> > <cl...@gmail.com> wrote:
> > >
> > > How tests are simulated within maven-surefire? is there any example?
> >
> > I mean... a test testing the test! Something that will call surefire
> > and its unit tests and validate outcome?
> >
>
> There are many integration tests in the surefire repository.
> Initially it is not straightforward to understand but it works.
> Unfortunately it passed some time since I wrote tests for surefire.
>
> I hope that others in this list my help
>
> Enrico
>
> >
> > >
> > > Would I be able to create an optional module where I do a test-leak
> > > using my library to validate if it leaked or not?
> > >
> > > On Tue, Jul 11, 2023 at 5:33 PM Clebert Suconic
> > > <cl...@gmail.com> wrote:
> > > >
> > > > I tried looking at how I would contribute a fix, but I lacked an
> > > > understanding on how tests are performed in surefire.
> > > >
> > > > Also: would you accept a test that's using check-leak to prevent
> > > > future leaks like this? (maybe a separate sub-module for this
> > > > test?)... and where I would add such test?
> > > >
> > > > I would even dedicate my personal time into proposing a fix if I can
> > > > get some basic understanding about this.
> > > >
> > > >
> > > > Is there a chat channel I can ask questions about the codebase? or
> the
> > > > user's or dev's list is a good place to start?
> > > >
> > > > On Tue, Jul 11, 2023 at 5:24 PM Enrico Olivelli <eolivelli@gmail.com
> >
> > wrote:
> > > > >
> > > > > Clebert,
> > > > >
> > > > >
> > > > >
> > > > > Il Mar 11 Lug 2023, 15:55 Clebert Suconic <
> clebert.suconic@gmail.com>
> > ha
> > > > > scritto:
> > > > >
> > > > > > created a JIRA:
> > > > > >
> > > > > > https://issues.apache.org/jira/browse/SUREFIRE-2186
> > > > >
> > > > >
> > > > >
> > > > > Thanks.
> > > > > Would you have time to contribute a fix?
> > > > >
> > > > > Enrico
> > > > >
> > > > > >
> > > > > >
> > > > > > On Tue, Jul 11, 2023 at 9:33 AM Clebert Suconic
> > > > > > <cl...@gmail.com> wrote:
> > > > > > >
> > > > > > > You guys need to be careful with non static ThreadLocals.
> > > > > > >
> > > > > > >
> > > > > > > ClassMethodIndexer has a non static ThreadLocal.
> > > > > > >
> > > > > > > threadLocals will create a hashEntry somewhere deep in the JDK.
> > > > > > > Depending on the number of tests that are running you guys may
> > break
> > > > > > > things like ReadWriteLock because it will transverse a lot of
> > entries.
> > > > > > > (I have been bitten by this before).
> > > > > > >
> > > > > > >
> > > > > > > Also, I have a reproducer:
> > > > > > >
> > > > > > >
> > > > > > > git clone
> > https://github.com/clebertsuconic/surefire-reproducer.git
> > > > > > > cd surefire-reproducer
> > > > > > > mvn install
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > This little project is using check-leak to count the number of
> > > > > > > instances of ClassObject. I have set the assertions as max 20
> > > > > > > instances. I have a copy&paste test that is validating this
> over
> > and
> > > > > > > over.
> > > > > > >
> > > > > > >
> > > > > > > And it's always leaking inside a ConcurrentHashMap that's being
> > held
> > > > > > > by ClassMethodIndex which is used by JUnit4Listener.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > and you guys should really stop using non static ThreadLocals..
> > I have
> > > > > > > found another case where it was used but at least the remove
> was
> > > > > > > called.. but still a bit scary to my test (It should just use a
> > static
> > > > > > > final... what's the point of a ThreadLocal if it's not static
> on
> > a
> > > > > > > class an associated to the instance?)
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Should I open a JIRA about this?
> > > > > > >
> > > > > > > On Mon, Jul 10, 2023 at 2:13 PM Clebert Suconic
> > > > > > > <cl...@gmail.com> wrote:
> > > > > > > >
> > > > > > > > We have recently upgraded surefire into artemis  from 2.x,
> and
> > > > > > > > strangely our testsuite started to crash because of memory.
> > > > > > > >
> > > > > > > >
> > > > > > > > So, it happens that I had other memory leaks in the past and
> I
> > became
> > > > > > > > addicted into finding them, up to a point that I created a
> > project
> > > > > > > > that will track memory usage over a java app, or be used on
> > test cases
> > > > > > > > to make sure leaks are not happening:
> > > > > > > >
> > > > > > > >
> > > > > > > > https://github.com/check-leak/check-leak
> > > > > > > >
> > > > > > > >
> > > > > > > > So,
> > > > > > > >
> > > > > > > >
> > > > > > > > I ran this testsuite from artemis:
> > > > > > > >
> > > > > > > > git clone git@github.com:apache/activemq-artemis.git
> > > > > > > > cd activemq-artemis
> > > > > > > > mvn install -DskipTests=true
> > > > > > > > cd tests/integration-tests
> > > > > > > > mvn -Ptests tests
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > get check-leak:
> > > > > > > > curl
> > > > > >
> >
> https://github.com/check-leak/check-leak/releases/download/0.11/check-leak-0.11.jar
> > > > > > > >
> > > > > > > > so after finding the process ID for the surefire:
> > > > > > > > java -jar check-leak-0.11.jar --sleep 5000 --pid
> <surefire-pid>
> > > > > > > > --report ./report-leak
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > As the test progress, open ./report-leak/index.html
> > > > > > > >
> > > > > > > >
> > > > > > > > you may refresh the page as the process go.
> > > > > > > >
> > > > > > > >
> > > > > > > > and if you look at the objects  allocations for
> > > > > > > > org.apache.maven.surefire.api.util.internal.ClassMethod, the
> > > > > > > > allocations are only growing after the lates version, and
> > never being
> > > > > > > > released.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > is there any idea about what might be causing it?
> > > > > > > >
> > > > > > > >
> > > > > > > > if you have a big project with many tests like I do, memory
> > > > > > > > allocations may be an issue and I would need to use a bigger
> > VM just
> > > > > > > > because of this probably leak.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Clebert Suconic
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Clebert Suconic
> > > > > >
> > > > > >
> > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > > > > For additional commands, e-mail: users-help@maven.apache.org
> > > > > >
> > > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Clebert Suconic
> > >
> > >
> > >
> > > --
> > > Clebert Suconic
> >
> >
> >
> > --
> > Clebert Suconic
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>

Re: Surefire leaking ClassMethod

Posted by Enrico Olivelli <eo...@gmail.com>.
Il Mer 12 Lug 2023, 00:15 Clebert Suconic <cl...@gmail.com> ha
scritto:

> On Tue, Jul 11, 2023 at 6:13 PM Clebert Suconic
> <cl...@gmail.com> wrote:
> >
> > How tests are simulated within maven-surefire? is there any example?
>
> I mean... a test testing the test! Something that will call surefire
> and its unit tests and validate outcome?
>

There are many integration tests in the surefire repository.
Initially it is not straightforward to understand but it works.
Unfortunately it passed some time since I wrote tests for surefire.

I hope that others in this list my help

Enrico

>
> >
> > Would I be able to create an optional module where I do a test-leak
> > using my library to validate if it leaked or not?
> >
> > On Tue, Jul 11, 2023 at 5:33 PM Clebert Suconic
> > <cl...@gmail.com> wrote:
> > >
> > > I tried looking at how I would contribute a fix, but I lacked an
> > > understanding on how tests are performed in surefire.
> > >
> > > Also: would you accept a test that's using check-leak to prevent
> > > future leaks like this? (maybe a separate sub-module for this
> > > test?)... and where I would add such test?
> > >
> > > I would even dedicate my personal time into proposing a fix if I can
> > > get some basic understanding about this.
> > >
> > >
> > > Is there a chat channel I can ask questions about the codebase? or the
> > > user's or dev's list is a good place to start?
> > >
> > > On Tue, Jul 11, 2023 at 5:24 PM Enrico Olivelli <eo...@gmail.com>
> wrote:
> > > >
> > > > Clebert,
> > > >
> > > >
> > > >
> > > > Il Mar 11 Lug 2023, 15:55 Clebert Suconic <cl...@gmail.com>
> ha
> > > > scritto:
> > > >
> > > > > created a JIRA:
> > > > >
> > > > > https://issues.apache.org/jira/browse/SUREFIRE-2186
> > > >
> > > >
> > > >
> > > > Thanks.
> > > > Would you have time to contribute a fix?
> > > >
> > > > Enrico
> > > >
> > > > >
> > > > >
> > > > > On Tue, Jul 11, 2023 at 9:33 AM Clebert Suconic
> > > > > <cl...@gmail.com> wrote:
> > > > > >
> > > > > > You guys need to be careful with non static ThreadLocals.
> > > > > >
> > > > > >
> > > > > > ClassMethodIndexer has a non static ThreadLocal.
> > > > > >
> > > > > > threadLocals will create a hashEntry somewhere deep in the JDK.
> > > > > > Depending on the number of tests that are running you guys may
> break
> > > > > > things like ReadWriteLock because it will transverse a lot of
> entries.
> > > > > > (I have been bitten by this before).
> > > > > >
> > > > > >
> > > > > > Also, I have a reproducer:
> > > > > >
> > > > > >
> > > > > > git clone
> https://github.com/clebertsuconic/surefire-reproducer.git
> > > > > > cd surefire-reproducer
> > > > > > mvn install
> > > > > >
> > > > > >
> > > > > >
> > > > > > This little project is using check-leak to count the number of
> > > > > > instances of ClassObject. I have set the assertions as max 20
> > > > > > instances. I have a copy&paste test that is validating this over
> and
> > > > > > over.
> > > > > >
> > > > > >
> > > > > > And it's always leaking inside a ConcurrentHashMap that's being
> held
> > > > > > by ClassMethodIndex which is used by JUnit4Listener.
> > > > > >
> > > > > >
> > > > > >
> > > > > > and you guys should really stop using non static ThreadLocals..
> I have
> > > > > > found another case where it was used but at least the remove was
> > > > > > called.. but still a bit scary to my test (It should just use a
> static
> > > > > > final... what's the point of a ThreadLocal if it's not static on
> a
> > > > > > class an associated to the instance?)
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Should I open a JIRA about this?
> > > > > >
> > > > > > On Mon, Jul 10, 2023 at 2:13 PM Clebert Suconic
> > > > > > <cl...@gmail.com> wrote:
> > > > > > >
> > > > > > > We have recently upgraded surefire into artemis  from 2.x, and
> > > > > > > strangely our testsuite started to crash because of memory.
> > > > > > >
> > > > > > >
> > > > > > > So, it happens that I had other memory leaks in the past and I
> became
> > > > > > > addicted into finding them, up to a point that I created a
> project
> > > > > > > that will track memory usage over a java app, or be used on
> test cases
> > > > > > > to make sure leaks are not happening:
> > > > > > >
> > > > > > >
> > > > > > > https://github.com/check-leak/check-leak
> > > > > > >
> > > > > > >
> > > > > > > So,
> > > > > > >
> > > > > > >
> > > > > > > I ran this testsuite from artemis:
> > > > > > >
> > > > > > > git clone git@github.com:apache/activemq-artemis.git
> > > > > > > cd activemq-artemis
> > > > > > > mvn install -DskipTests=true
> > > > > > > cd tests/integration-tests
> > > > > > > mvn -Ptests tests
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > get check-leak:
> > > > > > > curl
> > > > >
> https://github.com/check-leak/check-leak/releases/download/0.11/check-leak-0.11.jar
> > > > > > >
> > > > > > > so after finding the process ID for the surefire:
> > > > > > > java -jar check-leak-0.11.jar --sleep 5000 --pid <surefire-pid>
> > > > > > > --report ./report-leak
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > As the test progress, open ./report-leak/index.html
> > > > > > >
> > > > > > >
> > > > > > > you may refresh the page as the process go.
> > > > > > >
> > > > > > >
> > > > > > > and if you look at the objects  allocations for
> > > > > > > org.apache.maven.surefire.api.util.internal.ClassMethod, the
> > > > > > > allocations are only growing after the lates version, and
> never being
> > > > > > > released.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > is there any idea about what might be causing it?
> > > > > > >
> > > > > > >
> > > > > > > if you have a big project with many tests like I do, memory
> > > > > > > allocations may be an issue and I would need to use a bigger
> VM just
> > > > > > > because of this probably leak.
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Clebert Suconic
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Clebert Suconic
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > > > For additional commands, e-mail: users-help@maven.apache.org
> > > > >
> > > > >
> > >
> > >
> > >
> > > --
> > > Clebert Suconic
> >
> >
> >
> > --
> > Clebert Suconic
>
>
>
> --
> Clebert Suconic
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Surefire leaking ClassMethod

Posted by Clebert Suconic <cl...@gmail.com>.
On Tue, Jul 11, 2023 at 6:13 PM Clebert Suconic
<cl...@gmail.com> wrote:
>
> How tests are simulated within maven-surefire? is there any example?

I mean... a test testing the test! Something that will call surefire
and its unit tests and validate outcome?

>
> Would I be able to create an optional module where I do a test-leak
> using my library to validate if it leaked or not?
>
> On Tue, Jul 11, 2023 at 5:33 PM Clebert Suconic
> <cl...@gmail.com> wrote:
> >
> > I tried looking at how I would contribute a fix, but I lacked an
> > understanding on how tests are performed in surefire.
> >
> > Also: would you accept a test that's using check-leak to prevent
> > future leaks like this? (maybe a separate sub-module for this
> > test?)... and where I would add such test?
> >
> > I would even dedicate my personal time into proposing a fix if I can
> > get some basic understanding about this.
> >
> >
> > Is there a chat channel I can ask questions about the codebase? or the
> > user's or dev's list is a good place to start?
> >
> > On Tue, Jul 11, 2023 at 5:24 PM Enrico Olivelli <eo...@gmail.com> wrote:
> > >
> > > Clebert,
> > >
> > >
> > >
> > > Il Mar 11 Lug 2023, 15:55 Clebert Suconic <cl...@gmail.com> ha
> > > scritto:
> > >
> > > > created a JIRA:
> > > >
> > > > https://issues.apache.org/jira/browse/SUREFIRE-2186
> > >
> > >
> > >
> > > Thanks.
> > > Would you have time to contribute a fix?
> > >
> > > Enrico
> > >
> > > >
> > > >
> > > > On Tue, Jul 11, 2023 at 9:33 AM Clebert Suconic
> > > > <cl...@gmail.com> wrote:
> > > > >
> > > > > You guys need to be careful with non static ThreadLocals.
> > > > >
> > > > >
> > > > > ClassMethodIndexer has a non static ThreadLocal.
> > > > >
> > > > > threadLocals will create a hashEntry somewhere deep in the JDK.
> > > > > Depending on the number of tests that are running you guys may break
> > > > > things like ReadWriteLock because it will transverse a lot of entries.
> > > > > (I have been bitten by this before).
> > > > >
> > > > >
> > > > > Also, I have a reproducer:
> > > > >
> > > > >
> > > > > git clone https://github.com/clebertsuconic/surefire-reproducer.git
> > > > > cd surefire-reproducer
> > > > > mvn install
> > > > >
> > > > >
> > > > >
> > > > > This little project is using check-leak to count the number of
> > > > > instances of ClassObject. I have set the assertions as max 20
> > > > > instances. I have a copy&paste test that is validating this over and
> > > > > over.
> > > > >
> > > > >
> > > > > And it's always leaking inside a ConcurrentHashMap that's being held
> > > > > by ClassMethodIndex which is used by JUnit4Listener.
> > > > >
> > > > >
> > > > >
> > > > > and you guys should really stop using non static ThreadLocals.. I have
> > > > > found another case where it was used but at least the remove was
> > > > > called.. but still a bit scary to my test (It should just use a static
> > > > > final... what's the point of a ThreadLocal if it's not static on a
> > > > > class an associated to the instance?)
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Should I open a JIRA about this?
> > > > >
> > > > > On Mon, Jul 10, 2023 at 2:13 PM Clebert Suconic
> > > > > <cl...@gmail.com> wrote:
> > > > > >
> > > > > > We have recently upgraded surefire into artemis  from 2.x, and
> > > > > > strangely our testsuite started to crash because of memory.
> > > > > >
> > > > > >
> > > > > > So, it happens that I had other memory leaks in the past and I became
> > > > > > addicted into finding them, up to a point that I created a project
> > > > > > that will track memory usage over a java app, or be used on test cases
> > > > > > to make sure leaks are not happening:
> > > > > >
> > > > > >
> > > > > > https://github.com/check-leak/check-leak
> > > > > >
> > > > > >
> > > > > > So,
> > > > > >
> > > > > >
> > > > > > I ran this testsuite from artemis:
> > > > > >
> > > > > > git clone git@github.com:apache/activemq-artemis.git
> > > > > > cd activemq-artemis
> > > > > > mvn install -DskipTests=true
> > > > > > cd tests/integration-tests
> > > > > > mvn -Ptests tests
> > > > > >
> > > > > >
> > > > > >
> > > > > > get check-leak:
> > > > > > curl
> > > > https://github.com/check-leak/check-leak/releases/download/0.11/check-leak-0.11.jar
> > > > > >
> > > > > > so after finding the process ID for the surefire:
> > > > > > java -jar check-leak-0.11.jar --sleep 5000 --pid <surefire-pid>
> > > > > > --report ./report-leak
> > > > > >
> > > > > >
> > > > > >
> > > > > > As the test progress, open ./report-leak/index.html
> > > > > >
> > > > > >
> > > > > > you may refresh the page as the process go.
> > > > > >
> > > > > >
> > > > > > and if you look at the objects  allocations for
> > > > > > org.apache.maven.surefire.api.util.internal.ClassMethod, the
> > > > > > allocations are only growing after the lates version, and never being
> > > > > > released.
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > is there any idea about what might be causing it?
> > > > > >
> > > > > >
> > > > > > if you have a big project with many tests like I do, memory
> > > > > > allocations may be an issue and I would need to use a bigger VM just
> > > > > > because of this probably leak.
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Clebert Suconic
> > > >
> > > >
> > > >
> > > > --
> > > > Clebert Suconic
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > > For additional commands, e-mail: users-help@maven.apache.org
> > > >
> > > >
> >
> >
> >
> > --
> > Clebert Suconic
>
>
>
> --
> Clebert Suconic



-- 
Clebert Suconic

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire leaking ClassMethod

Posted by Clebert Suconic <cl...@gmail.com>.
How tests are simulated within maven-surefire? is there any example?

Would I be able to create an optional module where I do a test-leak
using my library to validate if it leaked or not?

On Tue, Jul 11, 2023 at 5:33 PM Clebert Suconic
<cl...@gmail.com> wrote:
>
> I tried looking at how I would contribute a fix, but I lacked an
> understanding on how tests are performed in surefire.
>
> Also: would you accept a test that's using check-leak to prevent
> future leaks like this? (maybe a separate sub-module for this
> test?)... and where I would add such test?
>
> I would even dedicate my personal time into proposing a fix if I can
> get some basic understanding about this.
>
>
> Is there a chat channel I can ask questions about the codebase? or the
> user's or dev's list is a good place to start?
>
> On Tue, Jul 11, 2023 at 5:24 PM Enrico Olivelli <eo...@gmail.com> wrote:
> >
> > Clebert,
> >
> >
> >
> > Il Mar 11 Lug 2023, 15:55 Clebert Suconic <cl...@gmail.com> ha
> > scritto:
> >
> > > created a JIRA:
> > >
> > > https://issues.apache.org/jira/browse/SUREFIRE-2186
> >
> >
> >
> > Thanks.
> > Would you have time to contribute a fix?
> >
> > Enrico
> >
> > >
> > >
> > > On Tue, Jul 11, 2023 at 9:33 AM Clebert Suconic
> > > <cl...@gmail.com> wrote:
> > > >
> > > > You guys need to be careful with non static ThreadLocals.
> > > >
> > > >
> > > > ClassMethodIndexer has a non static ThreadLocal.
> > > >
> > > > threadLocals will create a hashEntry somewhere deep in the JDK.
> > > > Depending on the number of tests that are running you guys may break
> > > > things like ReadWriteLock because it will transverse a lot of entries.
> > > > (I have been bitten by this before).
> > > >
> > > >
> > > > Also, I have a reproducer:
> > > >
> > > >
> > > > git clone https://github.com/clebertsuconic/surefire-reproducer.git
> > > > cd surefire-reproducer
> > > > mvn install
> > > >
> > > >
> > > >
> > > > This little project is using check-leak to count the number of
> > > > instances of ClassObject. I have set the assertions as max 20
> > > > instances. I have a copy&paste test that is validating this over and
> > > > over.
> > > >
> > > >
> > > > And it's always leaking inside a ConcurrentHashMap that's being held
> > > > by ClassMethodIndex which is used by JUnit4Listener.
> > > >
> > > >
> > > >
> > > > and you guys should really stop using non static ThreadLocals.. I have
> > > > found another case where it was used but at least the remove was
> > > > called.. but still a bit scary to my test (It should just use a static
> > > > final... what's the point of a ThreadLocal if it's not static on a
> > > > class an associated to the instance?)
> > > >
> > > >
> > > >
> > > >
> > > > Should I open a JIRA about this?
> > > >
> > > > On Mon, Jul 10, 2023 at 2:13 PM Clebert Suconic
> > > > <cl...@gmail.com> wrote:
> > > > >
> > > > > We have recently upgraded surefire into artemis  from 2.x, and
> > > > > strangely our testsuite started to crash because of memory.
> > > > >
> > > > >
> > > > > So, it happens that I had other memory leaks in the past and I became
> > > > > addicted into finding them, up to a point that I created a project
> > > > > that will track memory usage over a java app, or be used on test cases
> > > > > to make sure leaks are not happening:
> > > > >
> > > > >
> > > > > https://github.com/check-leak/check-leak
> > > > >
> > > > >
> > > > > So,
> > > > >
> > > > >
> > > > > I ran this testsuite from artemis:
> > > > >
> > > > > git clone git@github.com:apache/activemq-artemis.git
> > > > > cd activemq-artemis
> > > > > mvn install -DskipTests=true
> > > > > cd tests/integration-tests
> > > > > mvn -Ptests tests
> > > > >
> > > > >
> > > > >
> > > > > get check-leak:
> > > > > curl
> > > https://github.com/check-leak/check-leak/releases/download/0.11/check-leak-0.11.jar
> > > > >
> > > > > so after finding the process ID for the surefire:
> > > > > java -jar check-leak-0.11.jar --sleep 5000 --pid <surefire-pid>
> > > > > --report ./report-leak
> > > > >
> > > > >
> > > > >
> > > > > As the test progress, open ./report-leak/index.html
> > > > >
> > > > >
> > > > > you may refresh the page as the process go.
> > > > >
> > > > >
> > > > > and if you look at the objects  allocations for
> > > > > org.apache.maven.surefire.api.util.internal.ClassMethod, the
> > > > > allocations are only growing after the lates version, and never being
> > > > > released.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > is there any idea about what might be causing it?
> > > > >
> > > > >
> > > > > if you have a big project with many tests like I do, memory
> > > > > allocations may be an issue and I would need to use a bigger VM just
> > > > > because of this probably leak.
> > > >
> > > >
> > > >
> > > > --
> > > > Clebert Suconic
> > >
> > >
> > >
> > > --
> > > Clebert Suconic
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > > For additional commands, e-mail: users-help@maven.apache.org
> > >
> > >
>
>
>
> --
> Clebert Suconic



-- 
Clebert Suconic

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire leaking ClassMethod

Posted by Clebert Suconic <cl...@gmail.com>.
I tried looking at how I would contribute a fix, but I lacked an
understanding on how tests are performed in surefire.

Also: would you accept a test that's using check-leak to prevent
future leaks like this? (maybe a separate sub-module for this
test?)... and where I would add such test?

I would even dedicate my personal time into proposing a fix if I can
get some basic understanding about this.


Is there a chat channel I can ask questions about the codebase? or the
user's or dev's list is a good place to start?

On Tue, Jul 11, 2023 at 5:24 PM Enrico Olivelli <eo...@gmail.com> wrote:
>
> Clebert,
>
>
>
> Il Mar 11 Lug 2023, 15:55 Clebert Suconic <cl...@gmail.com> ha
> scritto:
>
> > created a JIRA:
> >
> > https://issues.apache.org/jira/browse/SUREFIRE-2186
>
>
>
> Thanks.
> Would you have time to contribute a fix?
>
> Enrico
>
> >
> >
> > On Tue, Jul 11, 2023 at 9:33 AM Clebert Suconic
> > <cl...@gmail.com> wrote:
> > >
> > > You guys need to be careful with non static ThreadLocals.
> > >
> > >
> > > ClassMethodIndexer has a non static ThreadLocal.
> > >
> > > threadLocals will create a hashEntry somewhere deep in the JDK.
> > > Depending on the number of tests that are running you guys may break
> > > things like ReadWriteLock because it will transverse a lot of entries.
> > > (I have been bitten by this before).
> > >
> > >
> > > Also, I have a reproducer:
> > >
> > >
> > > git clone https://github.com/clebertsuconic/surefire-reproducer.git
> > > cd surefire-reproducer
> > > mvn install
> > >
> > >
> > >
> > > This little project is using check-leak to count the number of
> > > instances of ClassObject. I have set the assertions as max 20
> > > instances. I have a copy&paste test that is validating this over and
> > > over.
> > >
> > >
> > > And it's always leaking inside a ConcurrentHashMap that's being held
> > > by ClassMethodIndex which is used by JUnit4Listener.
> > >
> > >
> > >
> > > and you guys should really stop using non static ThreadLocals.. I have
> > > found another case where it was used but at least the remove was
> > > called.. but still a bit scary to my test (It should just use a static
> > > final... what's the point of a ThreadLocal if it's not static on a
> > > class an associated to the instance?)
> > >
> > >
> > >
> > >
> > > Should I open a JIRA about this?
> > >
> > > On Mon, Jul 10, 2023 at 2:13 PM Clebert Suconic
> > > <cl...@gmail.com> wrote:
> > > >
> > > > We have recently upgraded surefire into artemis  from 2.x, and
> > > > strangely our testsuite started to crash because of memory.
> > > >
> > > >
> > > > So, it happens that I had other memory leaks in the past and I became
> > > > addicted into finding them, up to a point that I created a project
> > > > that will track memory usage over a java app, or be used on test cases
> > > > to make sure leaks are not happening:
> > > >
> > > >
> > > > https://github.com/check-leak/check-leak
> > > >
> > > >
> > > > So,
> > > >
> > > >
> > > > I ran this testsuite from artemis:
> > > >
> > > > git clone git@github.com:apache/activemq-artemis.git
> > > > cd activemq-artemis
> > > > mvn install -DskipTests=true
> > > > cd tests/integration-tests
> > > > mvn -Ptests tests
> > > >
> > > >
> > > >
> > > > get check-leak:
> > > > curl
> > https://github.com/check-leak/check-leak/releases/download/0.11/check-leak-0.11.jar
> > > >
> > > > so after finding the process ID for the surefire:
> > > > java -jar check-leak-0.11.jar --sleep 5000 --pid <surefire-pid>
> > > > --report ./report-leak
> > > >
> > > >
> > > >
> > > > As the test progress, open ./report-leak/index.html
> > > >
> > > >
> > > > you may refresh the page as the process go.
> > > >
> > > >
> > > > and if you look at the objects  allocations for
> > > > org.apache.maven.surefire.api.util.internal.ClassMethod, the
> > > > allocations are only growing after the lates version, and never being
> > > > released.
> > > >
> > > >
> > > >
> > > >
> > > > is there any idea about what might be causing it?
> > > >
> > > >
> > > > if you have a big project with many tests like I do, memory
> > > > allocations may be an issue and I would need to use a bigger VM just
> > > > because of this probably leak.
> > >
> > >
> > >
> > > --
> > > Clebert Suconic
> >
> >
> >
> > --
> > Clebert Suconic
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >



-- 
Clebert Suconic

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire leaking ClassMethod

Posted by Enrico Olivelli <eo...@gmail.com>.
Clebert,



Il Mar 11 Lug 2023, 15:55 Clebert Suconic <cl...@gmail.com> ha
scritto:

> created a JIRA:
>
> https://issues.apache.org/jira/browse/SUREFIRE-2186



Thanks.
Would you have time to contribute a fix?

Enrico

>
>
> On Tue, Jul 11, 2023 at 9:33 AM Clebert Suconic
> <cl...@gmail.com> wrote:
> >
> > You guys need to be careful with non static ThreadLocals.
> >
> >
> > ClassMethodIndexer has a non static ThreadLocal.
> >
> > threadLocals will create a hashEntry somewhere deep in the JDK.
> > Depending on the number of tests that are running you guys may break
> > things like ReadWriteLock because it will transverse a lot of entries.
> > (I have been bitten by this before).
> >
> >
> > Also, I have a reproducer:
> >
> >
> > git clone https://github.com/clebertsuconic/surefire-reproducer.git
> > cd surefire-reproducer
> > mvn install
> >
> >
> >
> > This little project is using check-leak to count the number of
> > instances of ClassObject. I have set the assertions as max 20
> > instances. I have a copy&paste test that is validating this over and
> > over.
> >
> >
> > And it's always leaking inside a ConcurrentHashMap that's being held
> > by ClassMethodIndex which is used by JUnit4Listener.
> >
> >
> >
> > and you guys should really stop using non static ThreadLocals.. I have
> > found another case where it was used but at least the remove was
> > called.. but still a bit scary to my test (It should just use a static
> > final... what's the point of a ThreadLocal if it's not static on a
> > class an associated to the instance?)
> >
> >
> >
> >
> > Should I open a JIRA about this?
> >
> > On Mon, Jul 10, 2023 at 2:13 PM Clebert Suconic
> > <cl...@gmail.com> wrote:
> > >
> > > We have recently upgraded surefire into artemis  from 2.x, and
> > > strangely our testsuite started to crash because of memory.
> > >
> > >
> > > So, it happens that I had other memory leaks in the past and I became
> > > addicted into finding them, up to a point that I created a project
> > > that will track memory usage over a java app, or be used on test cases
> > > to make sure leaks are not happening:
> > >
> > >
> > > https://github.com/check-leak/check-leak
> > >
> > >
> > > So,
> > >
> > >
> > > I ran this testsuite from artemis:
> > >
> > > git clone git@github.com:apache/activemq-artemis.git
> > > cd activemq-artemis
> > > mvn install -DskipTests=true
> > > cd tests/integration-tests
> > > mvn -Ptests tests
> > >
> > >
> > >
> > > get check-leak:
> > > curl
> https://github.com/check-leak/check-leak/releases/download/0.11/check-leak-0.11.jar
> > >
> > > so after finding the process ID for the surefire:
> > > java -jar check-leak-0.11.jar --sleep 5000 --pid <surefire-pid>
> > > --report ./report-leak
> > >
> > >
> > >
> > > As the test progress, open ./report-leak/index.html
> > >
> > >
> > > you may refresh the page as the process go.
> > >
> > >
> > > and if you look at the objects  allocations for
> > > org.apache.maven.surefire.api.util.internal.ClassMethod, the
> > > allocations are only growing after the lates version, and never being
> > > released.
> > >
> > >
> > >
> > >
> > > is there any idea about what might be causing it?
> > >
> > >
> > > if you have a big project with many tests like I do, memory
> > > allocations may be an issue and I would need to use a bigger VM just
> > > because of this probably leak.
> >
> >
> >
> > --
> > Clebert Suconic
>
>
>
> --
> Clebert Suconic
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Surefire leaking ClassMethod

Posted by Clebert Suconic <cl...@gmail.com>.
created a JIRA:

https://issues.apache.org/jira/browse/SUREFIRE-2186

On Tue, Jul 11, 2023 at 9:33 AM Clebert Suconic
<cl...@gmail.com> wrote:
>
> You guys need to be careful with non static ThreadLocals.
>
>
> ClassMethodIndexer has a non static ThreadLocal.
>
> threadLocals will create a hashEntry somewhere deep in the JDK.
> Depending on the number of tests that are running you guys may break
> things like ReadWriteLock because it will transverse a lot of entries.
> (I have been bitten by this before).
>
>
> Also, I have a reproducer:
>
>
> git clone https://github.com/clebertsuconic/surefire-reproducer.git
> cd surefire-reproducer
> mvn install
>
>
>
> This little project is using check-leak to count the number of
> instances of ClassObject. I have set the assertions as max 20
> instances. I have a copy&paste test that is validating this over and
> over.
>
>
> And it's always leaking inside a ConcurrentHashMap that's being held
> by ClassMethodIndex which is used by JUnit4Listener.
>
>
>
> and you guys should really stop using non static ThreadLocals.. I have
> found another case where it was used but at least the remove was
> called.. but still a bit scary to my test (It should just use a static
> final... what's the point of a ThreadLocal if it's not static on a
> class an associated to the instance?)
>
>
>
>
> Should I open a JIRA about this?
>
> On Mon, Jul 10, 2023 at 2:13 PM Clebert Suconic
> <cl...@gmail.com> wrote:
> >
> > We have recently upgraded surefire into artemis  from 2.x, and
> > strangely our testsuite started to crash because of memory.
> >
> >
> > So, it happens that I had other memory leaks in the past and I became
> > addicted into finding them, up to a point that I created a project
> > that will track memory usage over a java app, or be used on test cases
> > to make sure leaks are not happening:
> >
> >
> > https://github.com/check-leak/check-leak
> >
> >
> > So,
> >
> >
> > I ran this testsuite from artemis:
> >
> > git clone git@github.com:apache/activemq-artemis.git
> > cd activemq-artemis
> > mvn install -DskipTests=true
> > cd tests/integration-tests
> > mvn -Ptests tests
> >
> >
> >
> > get check-leak:
> > curl https://github.com/check-leak/check-leak/releases/download/0.11/check-leak-0.11.jar
> >
> > so after finding the process ID for the surefire:
> > java -jar check-leak-0.11.jar --sleep 5000 --pid <surefire-pid>
> > --report ./report-leak
> >
> >
> >
> > As the test progress, open ./report-leak/index.html
> >
> >
> > you may refresh the page as the process go.
> >
> >
> > and if you look at the objects  allocations for
> > org.apache.maven.surefire.api.util.internal.ClassMethod, the
> > allocations are only growing after the lates version, and never being
> > released.
> >
> >
> >
> >
> > is there any idea about what might be causing it?
> >
> >
> > if you have a big project with many tests like I do, memory
> > allocations may be an issue and I would need to use a bigger VM just
> > because of this probably leak.
>
>
>
> --
> Clebert Suconic



-- 
Clebert Suconic

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Surefire leaking ClassMethod

Posted by Clebert Suconic <cl...@gmail.com>.
You guys need to be careful with non static ThreadLocals.


ClassMethodIndexer has a non static ThreadLocal.

threadLocals will create a hashEntry somewhere deep in the JDK.
Depending on the number of tests that are running you guys may break
things like ReadWriteLock because it will transverse a lot of entries.
(I have been bitten by this before).


Also, I have a reproducer:


git clone https://github.com/clebertsuconic/surefire-reproducer.git
cd surefire-reproducer
mvn install



This little project is using check-leak to count the number of
instances of ClassObject. I have set the assertions as max 20
instances. I have a copy&paste test that is validating this over and
over.


And it's always leaking inside a ConcurrentHashMap that's being held
by ClassMethodIndex which is used by JUnit4Listener.



and you guys should really stop using non static ThreadLocals.. I have
found another case where it was used but at least the remove was
called.. but still a bit scary to my test (It should just use a static
final... what's the point of a ThreadLocal if it's not static on a
class an associated to the instance?)




Should I open a JIRA about this?

On Mon, Jul 10, 2023 at 2:13 PM Clebert Suconic
<cl...@gmail.com> wrote:
>
> We have recently upgraded surefire into artemis  from 2.x, and
> strangely our testsuite started to crash because of memory.
>
>
> So, it happens that I had other memory leaks in the past and I became
> addicted into finding them, up to a point that I created a project
> that will track memory usage over a java app, or be used on test cases
> to make sure leaks are not happening:
>
>
> https://github.com/check-leak/check-leak
>
>
> So,
>
>
> I ran this testsuite from artemis:
>
> git clone git@github.com:apache/activemq-artemis.git
> cd activemq-artemis
> mvn install -DskipTests=true
> cd tests/integration-tests
> mvn -Ptests tests
>
>
>
> get check-leak:
> curl https://github.com/check-leak/check-leak/releases/download/0.11/check-leak-0.11.jar
>
> so after finding the process ID for the surefire:
> java -jar check-leak-0.11.jar --sleep 5000 --pid <surefire-pid>
> --report ./report-leak
>
>
>
> As the test progress, open ./report-leak/index.html
>
>
> you may refresh the page as the process go.
>
>
> and if you look at the objects  allocations for
> org.apache.maven.surefire.api.util.internal.ClassMethod, the
> allocations are only growing after the lates version, and never being
> released.
>
>
>
>
> is there any idea about what might be causing it?
>
>
> if you have a big project with many tests like I do, memory
> allocations may be an issue and I would need to use a bigger VM just
> because of this probably leak.



-- 
Clebert Suconic

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org