Skip to content

Commit

Permalink
fix(core): improve ifc memory clean logic
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Aug 9, 2024
1 parent b1bb30a commit 8d3099c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thatopen/components",
"description": "Collection of core functionalities to author BIM apps.",
"version": "2.1.21",
"version": "2.1.22",
"author": "That Open Company",
"contributors": [
"Antonio Gonzalez Viegas (https://github.com/agviegas)",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/core/Components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Components implements Disposable {
/**
* The version of the @thatopen/components library.
*/
static readonly release = "2.1.21";
static readonly release = "2.1.22";

/** {@link Disposable.onDisposed} */
readonly onDisposed = new Event<void>();
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/fragments/IfcGeometryTiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,11 @@ export class IfcGeometryTiler extends Component implements Disposable {
}

private cleanUp() {
this.webIfc.Dispose();
try {
this.webIfc.Dispose();
} catch (e) {
// Problem disposing memory (maybe already disposed?)
}
(this.webIfc as any) = null;
this.webIfc = new WEBIFC.IfcAPI();
this._visitedGeometries.clear();
Expand Down
11 changes: 10 additions & 1 deletion packages/core/src/fragments/IfcLoader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export class IfcLoader extends Component implements Disposable {

/** {@link Disposable.dispose} */
dispose() {
try {
this.webIfc.Dispose();
} catch (e) {
// web-ifc couldn't be disposed
}
(this.webIfc as any) = null;
this.onDisposed.trigger(IfcLoader.uuid);
this.onDisposed.reset();
Expand Down Expand Up @@ -198,7 +203,11 @@ export class IfcLoader extends Component implements Disposable {
* ```
*/
cleanUp() {
this.webIfc.Dispose();
try {
this.webIfc.Dispose();
} catch (e) {
// web-ifc couldn't be disposed
}
(this.webIfc as any) = null; // Clear the reference to the Web-IFC library
this.webIfc = new WEBIFC.IfcAPI(); // Create a new instance of the Web-IFC library
this._visitedFragments.clear(); // Clear the map of visited fragments
Expand Down

0 comments on commit 8d3099c

Please sign in to comment.