Skip to content

Commit 8d3099c

Browse files
committed
fix(core): improve ifc memory clean logic
1 parent b1bb30a commit 8d3099c

4 files changed

Lines changed: 17 additions & 4 deletions

File tree

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thatopen/components",
33
"description": "Collection of core functionalities to author BIM apps.",
4-
"version": "2.1.21",
4+
"version": "2.1.22",
55
"author": "That Open Company",
66
"contributors": [
77
"Antonio Gonzalez Viegas (https://github.com/agviegas)",

packages/core/src/core/Components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class Components implements Disposable {
1414
/**
1515
* The version of the @thatopen/components library.
1616
*/
17-
static readonly release = "2.1.21";
17+
static readonly release = "2.1.22";
1818

1919
/** {@link Disposable.onDisposed} */
2020
readonly onDisposed = new Event<void>();

packages/core/src/fragments/IfcGeometryTiler/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,11 @@ export class IfcGeometryTiler extends Component implements Disposable {
298298
}
299299

300300
private cleanUp() {
301-
this.webIfc.Dispose();
301+
try {
302+
this.webIfc.Dispose();
303+
} catch (e) {
304+
// Problem disposing memory (maybe already disposed?)
305+
}
302306
(this.webIfc as any) = null;
303307
this.webIfc = new WEBIFC.IfcAPI();
304308
this._visitedGeometries.clear();

packages/core/src/fragments/IfcLoader/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ export class IfcLoader extends Component implements Disposable {
7171

7272
/** {@link Disposable.dispose} */
7373
dispose() {
74+
try {
75+
this.webIfc.Dispose();
76+
} catch (e) {
77+
// web-ifc couldn't be disposed
78+
}
7479
(this.webIfc as any) = null;
7580
this.onDisposed.trigger(IfcLoader.uuid);
7681
this.onDisposed.reset();
@@ -198,7 +203,11 @@ export class IfcLoader extends Component implements Disposable {
198203
* ```
199204
*/
200205
cleanUp() {
201-
this.webIfc.Dispose();
206+
try {
207+
this.webIfc.Dispose();
208+
} catch (e) {
209+
// web-ifc couldn't be disposed
210+
}
202211
(this.webIfc as any) = null; // Clear the reference to the Web-IFC library
203212
this.webIfc = new WEBIFC.IfcAPI(); // Create a new instance of the Web-IFC library
204213
this._visitedFragments.clear(); // Clear the map of visited fragments

0 commit comments

Comments
 (0)