Title: ifcopenshell: fix geom.iterator memory growth on the OCC path (#6904) by petruconduraru · Pull Request #8520 · IfcOpenShell/IfcOpenShell · GitHub
Open Graph Title: ifcopenshell: fix geom.iterator memory growth on the OCC path (#6904) by petruconduraru · Pull Request #8520 · IfcOpenShell/IfcOpenShell
X Title: ifcopenshell: fix geom.iterator memory growth on the OCC path (#6904) by petruconduraru · Pull Request #8520 · IfcOpenShell/IfcOpenShell
Description: Fixes #6904. Problem ifcopenshell.geom.iterator grows in memory when use_python_opencascade=True. The reporter's memory_profiler traces show the OCC path climbing monotonically (roughly +184 MB over the run) while the default occt path stays flat. Cause On the pythonOCC path the iterator emits SERIALIZED elements, and each element's brep is deserialized by create_shape_from_serialization in geom/occ_utils.py. For OCC >= 7.8 this called the single-argument overload breptools.ReadFromString(brep_data). pythonOCC's own binding documents that overload as allocating and returning a new TopoDS_Shape on every call, and provides the by-reference overload ReadFromString(brep_data, shape) specifically "to prevent memory increase." The allocating overload was being used, so a fresh shape was created per element for the life of the iteration. Fix Use the by-reference overload against a pre-allocated TopoDS_Shape, falling back to the single-argument form (via TypeError) for older bindings that only expose it. One file, geom/occ_utils.py. Verification Reporter's traces: OCC path +184 MB monotonic vs occt path flat (+4.7 MB) — leak confirmed on their build. The C++ SERIALIZED brep production, isolated, is flat, so the growth is on the pythonOCC deserialization side, not the kernel. In isolation the by-reference overload is measurably flatter than the single-argument one on repeated real-brep deserialization, matching pythonOCC's documented intent. Note on scope: I could not reproduce the full in-process 184 MB locally, because loading a standalone conda pythonOCC alongside IfcOpenShell's bundled static OCCT causes a symbol clash that aborts the iterator's initialize() on my machine. The change targets exactly the documented growing-allocation overload the report points at and is verified flatter in isolation; the biggest improvement is expected on the older pythonOCC versions where the reporter saw it (they noted it as most noticeable on 0.8.2 / 0.8.3). @duming, if you can run your original profile against this branch it would be good to confirm the full drop on your model. This contribution was produced with the assistance of an AI coding tool.
Open Graph Description: Fixes #6904. Problem ifcopenshell.geom.iterator grows in memory when use_python_opencascade=True. The reporter's memory_profiler traces show the OCC path climbing monotonically (roughly +184 MB...
X Description: Fixes #6904. Problem ifcopenshell.geom.iterator grows in memory when use_python_opencascade=True. The reporter's memory_profiler traces show the OCC path climbing monotonically (roughly +18...
Opengraph URL: https://github.com/IfcOpenShell/IfcOpenShell/pull/8520
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:5f7dc886-e5c8-1fb9-a98d-5acda96ac9eb |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B5AC:334801:D3FD26:12162A2:6B055051 |
| html-safe-nonce | d5f896c8c1d73a9d34a7d89a6f5c217eea1846989bc75216001ccbd303086d14 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNUFDOjMzNDgwMTpEM0ZEMjY6MTIxNjJBMjo2QjA1NTA1MSIsInZpc2l0b3JfaWQiOiI4NTcyMzk4NjQxNzU3OTAwODgxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9c45f1ca297722cb18534ec3d664a808ba9b7eae56cc115adb00d39dfc360d5f |
| hovercard-subject-tag | pull_request:4036237829 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/IfcOpenShell/IfcOpenShell/pull/8520/files |
| twitter:image | https://avatars.githubusercontent.com/u/139251053?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/139251053?s=400&v=4 |
| og:image:alt | Fixes #6904. Problem ifcopenshell.geom.iterator grows in memory when use_python_opencascade=True. The reporter's memory_profiler traces show the OCC path climbing monotonically (roughly +184 MB... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/IfcOpenShell/IfcOpenShell git https://github.com/IfcOpenShell/IfcOpenShell.git |
| octolytics-dimension-user_id | 13692563 |
| octolytics-dimension-user_login | IfcOpenShell |
| octolytics-dimension-repository_id | 40473201 |
| octolytics-dimension-repository_nwo | IfcOpenShell/IfcOpenShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 40473201 |
| octolytics-dimension-repository_network_root_nwo | IfcOpenShell/IfcOpenShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 220e980097d94ce616d5d11fbd5316d208e3fc93 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width