How many molecules are in mols.smi? Have you looked at task manager to
see memory usage while running this?

You should move the initialisation of OBBuilder outside the loop. I
have a feeling you are eating up memory by creating this multple
times.

- Noel

On 3 December 2013 06:43, Joos Kiener <joos.kie...@gmail.com> wrote:
> This is confusing. This issue is some weird memory issue. At the end of this
> post is the most simple code I could come up with that reproduces the
> problem for me.
>
> I can make the code work by removing or commenting just any of the following
> lines (only one of them is enough):
>
> -  conformerSearch.SetScore(score); // will then use default
> OBRMSDConformerScore
>
> -  String str = StringUtils.join(strArray, ',');
>
> For the StringUtils part, the length of the array matters. 5000 still works,
> 8000 does not. However in my original application I completely removed that
> and it still has the issue. This tells me it is some weird memory problem
> that can be caused by generating long strings (but not limited to this).
> This issue then breaks OBEnergyConformerScore but not the default
> OBRMSDConformerScore.
>
> The error code from event viewer according to my google search means heap
> corruption.
>
> See below the mentioned code. It has a dependency on
> org.apache.commons.lang3.
>
> <code>
> package conformergenerator;
>
> import org.apache.commons.lang3.StringUtils;
> import org.openbabel.OBBuilder;
> import org.openbabel.OBConformerScore;
> import org.openbabel.OBConformerSearch;
> import org.openbabel.OBConversion;
> import org.openbabel.OBEnergyConformerScore;
> import org.openbabel.OBMol;
>
> public class App {
>
>     public static void main(String[] args) {
>
>         System.loadLibrary("openbabel_java");
>
>         System.out.println("Create OBMol from smiles");
>         OBConversion conv = new OBConversion();
>         OBMol mol = new OBMol();
>         conv.SetInFormat("smi");
>
>         boolean hasNext = conv.ReadFile(mol, "mols.smi");
>
>         String[] strArray = buildArray(10000);
>         while (hasNext) {
>             System.out.println("Adding Hydrogens");
>             mol.AddHydrogens();
>             System.out.println("Generate 3D coordinates");
>             OBBuilder builder = new OBBuilder();
>             builder.Build(mol);
>
>             System.out.println("Generate Conformers");
>             OBConformerSearch conformerSearch = new OBConformerSearch();
>             OBConformerScore score = new OBEnergyConformerScore();
>             conformerSearch.SetScore(score);
>
>             if (!conformerSearch.Setup(mol)) {
>                 String message = "Generating conformers failed.";
>                 throw new IllegalArgumentException(message);
>             }
>             conformerSearch.Search();
>             conformerSearch.GetConformers(mol);
>
>             String str = StringUtils.join(strArray, ',');
>             // the idea would be to add this as property to mol
>             // but not required for the code to fail
>
>             hasNext = conv.Read(mol);
>         }
>         System.out.println("Success!!!");
>     }
>
>     private static String[] buildArray(int numElements) {
>         String[] a = new String[numElements];
>         for (int i = 0; i < numElements; i++) {
>             a[i] = "a";
>         }
>         return a;
>     }
> }
> </code>
>
>
>
> --
> View this message in context: 
> http://forums.openbabel.org/Java-API-setting-OBConformerScore-will-crash-application-tp4656958p4656970.html
> Sent from the General discussion mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to