Skip to content

Commit a271f5c

Browse files
fix memory leaks
1 parent d8e4c85 commit a271f5c

20 files changed

+32
-17
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group 'io.tiledb'
12-
version '0.19.0-SNAPSHOT'
12+
version '0.19.82'
1313

1414
repositories {
1515
jcenter()

src/main/java/io/tiledb/java/api/Array.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -963,14 +963,14 @@ protected SWIGTYPE_p_tiledb_array_t getArrayp() {
963963

964964
/** Free's the native objects and closes the Array. */
965965
public synchronized void close() {
966+
if (schema != null) {
967+
schema.close();
968+
}
966969
if (arrayp != null && arraypp != null) {
967970
tiledb.tiledb_array_close(ctx.getCtxp(), arrayp);
968971
tiledb.tiledb_array_free(arraypp);
969972
arrayp = null;
970973
arraypp = null;
971-
if (schema != null) {
972-
schema.close();
973-
}
974974
}
975975
}
976976
}

src/main/java/io/tiledb/java/api/ArraySchema.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -802,15 +802,9 @@ public String toString() {
802802
public void close() {
803803
if (schemap != null) {
804804
tiledb.tiledb_array_schema_free(schemapp);
805+
tiledb.delete_tiledb_array_schema_tpp(schemapp);
805806
schemap = null;
806807
schemapp = null;
807808
}
808-
// TODO: remove
809-
if (attributes != null) {
810-
for (Map.Entry<String, Attribute> e : attributes.entrySet()) {
811-
e.getValue().close();
812-
}
813-
}
814-
attributes = null;
815809
}
816810
}

src/main/java/io/tiledb/java/api/ArraySchemaEvolution.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ protected Context getCtx() {
4141
public void close() {
4242
if (evolutionp != null && evolutionpp != null) {
4343
tiledb.tiledb_array_schema_evolution_free(evolutionpp);
44+
tiledb.delete_tiledb_array_schema_evolution_tpp(evolutionpp);
4445
evolutionpp = null;
4546
evolutionp = null;
4647
}

src/main/java/io/tiledb/java/api/Attribute.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ public String toString() {
546546
public void close() {
547547
if (attributep != null) {
548548
tiledb.tiledb_attribute_free(attributepp);
549+
tiledb.delete_tiledb_attribute_tpp(attributepp);
549550
attributep = null;
550551
attributepp = null;
551552
}

src/main/java/io/tiledb/java/api/Config.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ protected SWIGTYPE_p_tiledb_config_t getConfigp() {
357357
public void close() {
358358
if (configp != null) {
359359
tiledb.tiledb_config_free(configpp);
360+
tiledb.delete_tiledb_config_tpp(configpp);
360361
configp = null;
361362
configpp = null;
362363
}

src/main/java/io/tiledb/java/api/ConsolidationPlan.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public long getNumNodes() throws TileDBError {
132132
public void close() throws Exception {
133133
if (consp != null) {
134134
tiledb.tiledb_consolidation_plan_free(conspp);
135+
tiledb.delete_tiledb_consolidation_plan_tpp(conspp);
135136
consp = null;
136137
conspp = null;
137138
}

src/main/java/io/tiledb/java/api/Context.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ public String getStats() throws TileDBError {
261261
public void close() {
262262
if (ctxp != null) {
263263
tiledb.tiledb_ctx_free(ctxpp);
264+
tiledb.delete_tiledb_ctx_tpp(ctxpp);
264265
ctxp = null;
265266
ctxpp = null;
266267
}

src/main/java/io/tiledb/java/api/Dimension.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ public String tileExtentToStr() throws TileDBError {
310310
public void close() {
311311
if (dimensionp != null) {
312312
tiledb.tiledb_dimension_free(dimensionpp);
313+
tiledb.delete_tiledb_dimension_tpp(dimensionpp);
313314
dimensionp = null;
314315
dimensionpp = null;
315316
}

src/main/java/io/tiledb/java/api/Domain.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,7 @@ public void addDimensions(Collection<Dimension> dims) throws TileDBError {
289289
public void close() {
290290
if (domainp != null) {
291291
tiledb.tiledb_domain_free(domainpp);
292-
}
293-
if (dimensions != null) {
294-
for (Dimension d : dimensions) {
295-
d.close();
296-
}
292+
tiledb.delete_tiledb_domain_tpp(domainpp);
297293
}
298294
}
299295
}

0 commit comments

Comments
 (0)