Commit ce3f7427 authored by Michael Sherman's avatar Michael Sherman
Browse files

Fix memory leak in C examples.

parent aac28a18
...@@ -26,11 +26,13 @@ void simulateArgon() ...@@ -26,11 +26,13 @@ void simulateArgon()
OpenMM_Platform* platform; OpenMM_Platform* platform;
OpenMM_NonbondedForce* nonbond; OpenMM_NonbondedForce* nonbond;
OpenMM_Vec3Array* initPosInNm; OpenMM_Vec3Array* initPosInNm;
OpenMM_StringArray* pluginList;
int a, frameNum; int a, frameNum;
/* Load any shared libraries containing GPU implementations. */ /* Load any shared libraries containing GPU implementations. */
OpenMM_Platform_loadPluginsFromDirectory( pluginList = OpenMM_Platform_loadPluginsFromDirectory(
OpenMM_Platform_getDefaultPluginsDirectory()); OpenMM_Platform_getDefaultPluginsDirectory());
OpenMM_StringArray_destroy(pluginList);
/* Create a system with nonbonded forces. System takes ownership /* Create a system with nonbonded forces. System takes ownership
of Force; don't destroy it yourself. */ of Force; don't destroy it yourself. */
......
...@@ -197,14 +197,16 @@ myInitializeOpenMM( const MyAtomInfo atoms[], ...@@ -197,14 +197,16 @@ myInitializeOpenMM( const MyAtomInfo atoms[],
MyOpenMMData* omm = (MyOpenMMData*)malloc(sizeof(struct MyOpenMMData_s)); MyOpenMMData* omm = (MyOpenMMData*)malloc(sizeof(struct MyOpenMMData_s));
/* These are temporary OpenMM objects used and discarded here. */ /* These are temporary OpenMM objects used and discarded here. */
OpenMM_Vec3Array* initialPosInNm; OpenMM_Vec3Array* initialPosInNm;
OpenMM_StringArray* pluginList;
OpenMM_NonbondedForce* nonbond; OpenMM_NonbondedForce* nonbond;
OpenMM_GBSAOBCForce* gbsa; OpenMM_GBSAOBCForce* gbsa;
OpenMM_Platform* platform; OpenMM_Platform* platform;
int n; int n;
/* Load all available OpenMM plugins from their default location. */ /* Load all available OpenMM plugins from their default location. */
OpenMM_Platform_loadPluginsFromDirectory pluginList = OpenMM_Platform_loadPluginsFromDirectory
(OpenMM_Platform_getDefaultPluginsDirectory()); (OpenMM_Platform_getDefaultPluginsDirectory());
OpenMM_StringArray_destroy(pluginList);
/* Create a System and Force objects within the System. Retain a reference /* Create a System and Force objects within the System. Retain a reference
* to each force object so we can fill in the forces. Note: the OpenMM * to each force object so we can fill in the forces. Note: the OpenMM
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment