Unable to delete the persistit_tempvol file after Executing sonar Embedded Runner from Java

199 views Asked by At

I have a set of project's on which I need to execute Sonar. Once I execute sonar task and it publishes the result it deletes all the files in the directory .sonartemp except the file persistit_tempvol. This file is locked by Java SE runtime and I am unable to delete this.

The reason I want to delete this file is once it starts executing another project it creates the same file for that project and the data from previous persistit_tempvol is still in Java Heap. So after I run few projects I actually go OutOfMemory.

I tried increaing the Heap memory, but the number of projects are very high ~100. I don't want to go one by one and execute them. I want to keep doing it in the loop.

I am running sonarrunner 2.4, windows 7, Java 8, sonar ant task 2.3, Sonar Qube 5.1

Here's how I am executing the sonar runner:

EmbeddedRunner.create().addProperties(properties)
            .unmask("org.apache.tools.ant").unmask("org.sonar.ant")
            .execute();

The properties is the property file of sonar.

I guess I cannot delete this file from sonar as it's locked by by my JVM. Is there a way I can delete this file?

2

There are 2 answers

0
anon On BEST ANSWER

ForkedRunner.create().addProperties(properties).execute();

That's all I had to do and it is working fine now. Thanks :)

4
Julien H. - SonarSource Team On

I guess you don't really need to pass Ant objects as extension so I suggest you give a try to ForkedRunner instead of EmbeddedRunner. This would allow you to start with a clean JVM for each analysis.

FYI we are currently working on improving the embedded mode to support running several consecutive analysis without any resource leak (SQ Runner 2.5 + SQ server 5.2).