Archived issue #0023631

Infinite memory consumption in BRepMesh

Open CASCADEOCCT:Meshclosed19 public notes

Search issues

Description

Command incmesh on the attached face consumes memory until bad_alloc (sometimes is handled, sometimes leads to crash of DRAW).

Steps to reproduce

Draw[]> restore Attachment 13 (BREP) a
Draw[]> incmesh a 1.195

Note that the result could be either crash (bad_alloc) or null triangulation.

Additional information

The problem is originally reproduced on shape originating from #396, when this shape is shown in 3d viewer by vdisplay command. It does not reproduce neither on original shape if its triangulation is cleaned, nor on isolated face (nb. 2903) from original shape. The attached face has been produced by the following commands:

Draw[]> restore [locate_data_file OCC396.brep] a
Draw[]> explode a f
Draw[]> for {set i 1} {$i <= 2911} {incr i} { puts "a_$i"; flush stdout; save a_$i OCC396_f$i.brep; incmesh a_$i 1.195; vdisplay a_$i; vfit }

Note that triangulation contained in original shape is corrupted: it contains nodes with too big co-ordinates. This can be seen by bounding box:

Draw[]> boundings a
-1174082187021974.5 -15670499.83326759 -5243270.1753272489 18193501.136063989 941785825294154.37 315117129541890.37

Public activity

19 archived notes

Participants are labeled by their role within this record.

01Commenter 2
It's amazing for me that the initial shape has different Poly_Triangulation stored at face and associated to a particular edge forming this face.

Nevertheless, fix has been implemented and pushed to GIT branch CR23631.

Dear Pavel,
please review.
02Commenter 2
The fix looks good but can slow down the algo. Please pay attention to performance (the possible solution to check in parallel)
03Commenter 3
Dear BugMaster,

Branch CR23631 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
[revision removed]

Number of compiler warnings:

occt component :
Linux: 945 (947 on master)
Windows: 891 (891 on master)

products component :
Linux: 188 (188 on master)
Windows: 287 (287 on master)

Regressions:
No regressions

Improvements:
No improvements

Testing cases:
bugs modalg_5(010) bug23631 - OK.

Testing on Linux:
http://occt-tests/CR23631-master-occt/Debian60-64/diff-Debian60-64.html
Total MEMORY difference: 363915608 / 363686308
Total CPU difference: 43326.04000000099 / 43423.52000000051

Testing on Windows:
http://occt-tests/CR23631-master-occt/Windows-32-VC9/diff-Windows-32-VC9.html
Total MEMORY difference: 424675320 / 424160228
Total CPU difference: 39214.859375 / 53402.8125

There are not differences in images found by testdiff.

Dear oan,
result shape is bad in test case bugs modalg_5(010) bug23631, could you please validate it.

04Commenter 2
Dear mkv,

please provide information about performance of the fix (elapsed time) on several "high-weighted" shapes containing a lot of edges and faces comparing to the results on master branch.

Regarding the shape attached to this bug - yes, "checkshape" notifies problems. However, it doesn't play a role in context of made fix.
05Commenter 1
Test case was move to bugs/mesh/bug23631 to avoid checkshape of the shape.
Test cases to show performance were attached. Results:

test1:
Elapsed Time: 41.988304 Seconds (42.099077 Seconds on master) size 10.2 MB

test2:
Elapsed Time: 1 Minutes 21.046335 Seconds (1 Minutes 23.302275 Seconds on master) size 18.5 MB

test3:
Elapsed Time: 46.410649 Seconds (48.648884 Seconds on master) size 34.9 MB

test4:
Elapsed Time: 4 Minutes 36.887112 Seconds (3 Minutes 7.600485 Seconds on master) size 59 MB

test5:
Elapsed Time: 6 Minutes 36.673735 Seconds (6 Minutes 23.286125 Seconds on master) size 50 MB step

test6:
Elapsed Time: 14 Minutes 38.85239 Seconds (7 Minutes 38.749197 Seconds on master) size 34.3 MB

06Commenter 1
test1:
Elapsed time: 36.886161736 Sec (34.8680336054 Sec on master) size 10.2 MB

test2:
Elapsed time: 1 Min 19.9720355166 Sec (1 Min 12.0869424647 Sec on master) size 18.5 MB

test3:
Elapsed time: 43.1618825403 Sec (39.0547405136 Sec on master) size 34.9 MB

test4:
Elapsed time: 4 Min 18.8491976906 Sec (2 Min 32.3706683655 Sec on master) size 59 MB

test5:
Elapsed time: 4 Min 57.310111089 Sec (4 Min 30.3873219988 Sec on master) size 50 MB step

test6:
Elapsed time: 13 Min 36.5379462473 Sec (6 Min 43.301762612 Sec on master) size 34.3 MB

test01-test06:
http://occt-tests/23615_meshperformance_1/summary.html
http://occt-tests/23615_meshperformance_2/summary.html

07Commenter 2
The same fix but with possibility to perform the check in parallel depending on flag myInParallel. Please review changes in branch CR23631_1.
08Commenter 8
Dear BugMaster,

Branch CR23631_1 was compiled on Linux platform.
[revision removed]

There is extraction error:

Error : No file BRepMesh_IncrementalMesh.cdl in BRepMesh
Error : Failed during execution
Info : Failed BRepMesh (xcpp.fill xcpp.src xcpp.header xcpp.template obj.inc obj.comp obj.idep )
09Commenter 2
Dear MKV,
I have pushed changes of BRepMesh.cdl to the CR23631_1.
Please checkout it and repeat test campaign.
10Commenter 10
Dear BugMaster,

Branch CR23631_1 (and products from GIT master) was compiled on Windows platform.
[revision removed]

There are compilation errors:
http://jenkins-test-02.nnov.opencascade.com:8080/user/mnt/my-views/view/CR23631_1/job/mnt-CR23631_1-master_build_occt_windows/1/parsed_console/

27>..\..\..\src\StlTransfer\StlTransfer.cxx(35) : fatal error C1083: Cannot open include file: 'BRepMesh_IncrementalMesh.hxx': No such file or directory

28>..\..\..\inc\XBRepMesh.hxx(26) : fatal error C1083: Cannot open include file: 'BRepMesh_PDiscretRoot.hxx': No such file or directory

33>..\..\..\src\StdSelect\StdSelect_BRepSelectionTool.cxx(60) : fatal error C1083: Cannot open include file: 'BRepMesh_IncrementalMesh.hxx': No such file or directory

32>..\..\..\src\DBRep\DBRep_DrawableShape.cxx(44) : fatal error C1083: Cannot open include file: 'BRepMesh_IncrementalMesh.hxx': No such file or directory

33>..\..\..\inc\StdPrs_ToolShadedShape.hxx(20) : fatal error C1083: Cannot open include file: 'BRepMesh_ShapeTool.hxx': No such file or directory

33>..\..\..\inc\StdPrs_ToolShadedShape.hxx(20) : fatal error C1083: Cannot open include file: 'BRepMesh_ShapeTool.hxx': No such file or directory
11Commenter 11
There are new additional warnings on Linux platform:

BRepMesh_EdgeChecker.hxx:39, GNU C Compiler 4 (gcc), Priority: Normal
when initialized here

BRepMesh_EdgeChecker.hxx:76, GNU C Compiler 4 (gcc), Priority: Normal
‘Standard_Mutex& BRepMesh_EdgeChecker::myMutex’

BRepMesh_EdgeChecker.hxx:78, GNU C Compiler 4 (gcc), Priority: Normal
‘BRepMesh_EdgeChecker::myFaceLoc’ will be initialized after

BRepMesh_EdgeChecker.hxx:78, GNU C Compiler 4 (gcc), Priority: Normal
‘TopLoc_Location& BRepMesh_EdgeChecker::myFaceLoc’

BRepMesh_EdgeChecker.hxx:79, GNU C Compiler 4 (gcc), Priority: Normal
‘BRepMesh_EdgeChecker::myFaceTri’ will be initialized after
12Commenter 2
Dear MKV,

I've compiled OCCT step-by-step from generating of project files by WOK. Compilation errors was not been reproduced. Corrective fix for warnings has been pushed to CR23631_1.

Could you please update the sources and run testing procedure from the ground.
13Commenter 13
Dear BugMaster,

Branch CR23631_1 (and products from GIT master) was compiled on Linux, MacOS and Windows platforms and tested.
[revision removed]

Number of compiler warnings:

occt component :
Linux: 16 (16 on master)
Windows: 0 (0 on master)


There are compilation errors on MacOs:

http://jenkins-test-02.nnov.opencascade.com:8080/user/mnt/my-views/view/CR23631_1/job/mnt-CR23631_1-master_prepare_build_occt_MacOS/1/parsed_console/
[user path removed]/tools/WOK670/wok_entities/LOC/dev/CR23631-1-master-occt/inc/BRepMesh_EdgeChecker.hxx:76:3: error: 'mutable' cannot be applied to references
mutable Standard_Mutex& myMutex;

[user path removed]/tools/WOK670/wok_entities/LOC/dev/CR23631-1-master-occt/inc/BRepMesh_EdgeChecker.hxx:77:3: error: 'mutable' cannot be applied to references
mutable Standard_Boolean& myIsFailed;


Regressions/Differences:
No regressions/differences

Testing cases:
http://occt-tests/CR23631-1-master-occt/Debian60-64/bugs/mesh/bug23631.html
http://occt-tests/CR23631-1-master-occt/Windows-32-VC9/bugs/mesh/bug23631.html
bugs mesh(016) bug23631 - OK

Testing on Linux:
Total MEMORY difference: 361042160 / 361239560
Total CPU difference: 51946.46999999973 / 53202.729999999996

Testing on Windows:
Total MEMORY difference: 383509904 / 383800460
Total CPU difference: 37566.484375 / 42820.09375

There are no differences in images found by testdiff.
14Commenter 2
Dear MKV,

Modificator mutable has been removed to fix compilation errors on MacOs.
Please test.

Could you please also run measurement test cases test01-test06 attached to this bug to investigate changes in performance.

Note that current implementation of measurement tests uses incmesh in consecutive mode. As far as updated fix has possibility to be executed in parallel, please provide additional measurement report for incmesh run in parallel (additional flag is necessary - e.g. incmesh a 0.01 1).
15Commenter 1
test01-test06:
http://occt-tests/23631_branch_test/summary.html
http://occt-tests/23631_master_test/summary.html

test1:
Elapsed time: 21.0582516864 Sec (20.5214065839 Sec on master) size 10.2 MB

test2:
Elapsed time: 42.0088274845 Sec (42.1832723727 Sec on master) size 18.5 MB

test3:
Elapsed time: 23.7721538514 Sec (23.0834505145 Sec on master) size 34.9 MB

test4:
Elapsed time: 2 Min 12.2787742996 Sec (1 Min 24.0340788336 Sec on master) size 59 MB

test5:
Elapsed time: 2 Min 27.6439726587 Sec (2 Min 25.8042220242 Sec on master) size 50 MB step

test6:
Elapsed time: 6 Min 32.6425076874 Sec (3 Min 28.3094323344 Sec on master) size 34.3 MB
16Commenter 1
Incmesh in parallel:
http://occt-tests/23631_branch_testparallel/summary.html

test1:
Elapsed time: 0 Hours 0 Minutes 9.2010350262 Seconds

test2:
Elapsed time: 0 Hours 0 Minutes 19.8777292317 Seconds

test3:
Elapsed time: 0 Hours 0 Minutes 13.2146363023 Seconds

test4:
Elapsed time: 0 Hours 0 Minutes 44.0383796063 Seconds

test5:
Elapsed time: 0 Hours 1 Minutes 4.30894775421 Seconds

test6:
Elapsed time: 0 Hours 3 Minutes 33.9908699419 Seconds
17Commenter 17
Dear BugMaster,

Branch CR23631_1 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
[revision removed]

Number of compiler warnings:

occt component :
Linux: 16 (16 on master)
Windows: 0 (0 on master)

products component :
Linux: 11 (11 on master)
Windows: 2 (2 on master)

Regressions/Differences:
sat doc_1(001) B8, O4
sat read_parallel(009) A1, A3, B6, C3, E2 - only on Linux
sat load(010) B3
sat simple(011) B3

Testing cases:
http://occt-tests/CR23631-1-master-occt/Debian60-64/bugs/mesh/bug23631.html
http://occt-tests/CR23631-1-master-occt/Windows-32-VC9/bugs/mesh/bug23631.html
bugs mesh(016) bug23631: OK

Testing on Linux:
Total MEMORY difference: 361112300 / 348911880
Total CPU difference: 52335.91000000001 / 52776.510000000024

Testing on Windows:
Total MEMORY difference: 383230020 / 376950988
Total CPU difference: 37953.453125 / 42280.578125

There are no differences in images found by testdiff.

18Commenter 2
Dear MKV,

reported Regressions/Differences have no connection with changes introduced in context of current issue as well as with incmesh in particular.

Please proceed the changes.

19Commenter 19
Dear BugMaster,

Branch CR223631_1 was rebased on current master and was recompiled on Linux, MacOS and Windows platforms and was retested.
[revision removed]

Number of compiler warnings:

occt component :
Linux: 16 (16 on master)
Windows: 0 (0 on master)
MacOS: 200 (203 on master)

products component :
Linux: 11 (11 on master)
Windows: 2 (2 on master)

Regressions/Differences:
No regressions/differences

Testing cases:
http://occt-tests/CR23631-1-master-occt/Debian60-64/bugs/mesh/bug23631.html
http://occt-tests/CR23631-1-master-occt/Windows-32-VC9/bugs/mesh/bug23631.html
bugs mesh(016) bug23631: OK

Testing on Linux:
Total MEMORY difference: 348356556 / 348271088
Total CPU difference: 50448.030000000035 / 51079.56999999988

Testing on Windows:
Total MEMORY difference: 376377616 / 376854496
Total CPU difference: 39271.703125 / 38860.21875

There are no differences in images found by testdiff.