Python: how to close doc after using OpenHeadless() ? / memory leak?

hi there,

I’m currently working on a script, that processes a few hundred .3dm files. I’m using RhinoDoc.OpenHeadless() to open the files and noticed, that memory keeps increasing.
Here is a simple script to reprocuce:

import Rhino
import scriptcontext as sc

filepath = r"myfile.3dm"

for i in range(100):
    doc = Rhino.RhinoDoc.OpenHeadless(filepath)
    if sc.escape_test(False):
        break

The files I’m working with are about 0.5-1MB and contain a bunch of different objects. I tried using .Dispose() as well as del doc. Both don’t change anything for me. This is on Rhino 7.34.23267.11001

Besides that, after the first few hundred files it gets slower and slower to process.

I assume, that there is still a reference to the opened file somewhere, that isn’t cleaned up.
Any ideas how to avoid this?

Thanks,
Bernd

Bump. Just tested on Rhino 8.2.23346.13001 same problem there.

The more files are checked, the longer it takes to open them. This also means that running the script multiple times makes each run slower than the previous, as in the second run in my case is already 10-20x slower than the first.

I appreciate any help with this.

Hi @Bernd_Möller,

Is this any better?

for i in range(100):
    doc = Rhino.RhinoDoc.OpenHeadless(filepath)
    if doc:
        doc.Dispose() # dispose...
    if sc.escape_test(False):
        break

– Dale

hi @dale, no, I’ve tried that on Rhino 7 already and it’s the same for Rhino 8. Also del doesn’t seem to make a difference.

I am encountering the same issue, even with the doc.Dispose() method. Everytime the python script is run it gets slower and slower. I really need this to work as I am using a custom script over Compute, Pancake or Eleftront don’t work over Compute. I am trying to export a series of gltfs from grasshopper geometries, the best I could do over Compute was to bake to 3dm file, then openheadless in rhino and write in gltf. Any suggestions welcome.

@Laoky

Does running this make your rhino slower?!

test_openHeadless.3dm is a rhino 8 file with a single sphere

#! python 3
import time

import scriptcontext as sc
import Rhino

for i in range(100):
    start = time.time()
    doc = Rhino.RhinoDoc.OpenHeadless(r'test_openHeadless.3dm')
    opened = doc is not None
    if opened:
        doc.Dispose()
    end = time.time()

    print(f"Iteration: {i} {end - start} {opened=}")

    if sc.escape_test(False):
        break

Here is the result on my machine:

Iteration: 0 0.09139537811279297 opened=True
Iteration: 1 0.056761741638183594 opened=True
Iteration: 2 0.05487489700317383 opened=True
Iteration: 3 0.06638884544372559 opened=True
Iteration: 4 0.0597686767578125 opened=True
Iteration: 5 0.062410831451416016 opened=True
Iteration: 6 0.05433249473571777 opened=True
Iteration: 7 0.059128761291503906 opened=True
Iteration: 8 0.04618215560913086 opened=True
Iteration: 9 0.0514678955078125 opened=True
Iteration: 10 0.04547691345214844 opened=True
Iteration: 11 0.0395658016204834 opened=True
Iteration: 12 0.05559659004211426 opened=True
Iteration: 13 0.061719655990600586 opened=True
Iteration: 14 0.038640499114990234 opened=True
Iteration: 15 0.04560446739196777 opened=True
Iteration: 16 0.03067803382873535 opened=True
Iteration: 17 0.034528255462646484 opened=True
Iteration: 18 0.04250645637512207 opened=True
Iteration: 19 0.04349803924560547 opened=True
Iteration: 20 0.03396320343017578 opened=True
Iteration: 21 0.03983950614929199 opened=True
Iteration: 22 0.03728199005126953 opened=True
Iteration: 23 0.04117989540100098 opened=True
Iteration: 24 0.030443429946899414 opened=True
Iteration: 25 0.029919862747192383 opened=True
Iteration: 26 0.030897855758666992 opened=True
Iteration: 27 0.030397653579711914 opened=True
Iteration: 28 0.032470703125 opened=True
Iteration: 29 0.03189706802368164 opened=True
Iteration: 30 0.04083108901977539 opened=True
Iteration: 31 0.03084874153137207 opened=True
Iteration: 32 0.03109908103942871 opened=True
Iteration: 33 0.03239750862121582 opened=True
Iteration: 34 0.03049612045288086 opened=True
Iteration: 35 0.030103206634521484 opened=True
Iteration: 36 0.03125739097595215 opened=True
Iteration: 37 0.033857107162475586 opened=True
Iteration: 38 0.03314924240112305 opened=True
Iteration: 39 0.03244948387145996 opened=True
Iteration: 40 0.030725955963134766 opened=True
Iteration: 41 0.03124523162841797 opened=True
Iteration: 42 0.030539989471435547 opened=True
Iteration: 43 0.037012577056884766 opened=True
Iteration: 44 0.036485910415649414 opened=True
Iteration: 45 0.038539886474609375 opened=True
Iteration: 46 0.03845620155334473 opened=True
Iteration: 47 0.038017988204956055 opened=True
Iteration: 48 0.0324559211730957 opened=True
Iteration: 49 0.03251314163208008 opened=True
Iteration: 50 0.03371143341064453 opened=True
Iteration: 51 0.031205415725708008 opened=True
Iteration: 52 0.0314030647277832 opened=True
Iteration: 53 0.04683518409729004 opened=True
Iteration: 54 0.04804587364196777 opened=True
Iteration: 55 0.03156876564025879 opened=True
Iteration: 56 0.03229260444641113 opened=True
Iteration: 57 0.03165316581726074 opened=True
Iteration: 58 0.031091690063476562 opened=True
Iteration: 59 0.032646894454956055 opened=True
Iteration: 60 0.0317838191986084 opened=True
Iteration: 61 0.03255867958068848 opened=True
Iteration: 62 0.030820608139038086 opened=True
Iteration: 63 0.03203153610229492 opened=True
Iteration: 64 0.03346824645996094 opened=True
Iteration: 65 0.03535056114196777 opened=True
Iteration: 66 0.043565988540649414 opened=True
Iteration: 67 0.04848980903625488 opened=True
Iteration: 68 0.031324148178100586 opened=True
Iteration: 69 0.03352689743041992 opened=True
Iteration: 70 0.03156614303588867 opened=True
Iteration: 71 0.032944440841674805 opened=True
Iteration: 72 0.0348963737487793 opened=True
Iteration: 73 0.035536766052246094 opened=True
Iteration: 74 0.03068852424621582 opened=True
Iteration: 75 0.034810781478881836 opened=True
Iteration: 76 0.030794620513916016 opened=True
Iteration: 77 0.038069725036621094 opened=True
Iteration: 78 0.03882741928100586 opened=True
Iteration: 79 0.030980825424194336 opened=True
Iteration: 80 0.031358957290649414 opened=True
Iteration: 81 0.031369686126708984 opened=True
Iteration: 82 0.03072190284729004 opened=True
Iteration: 83 0.0316615104675293 opened=True
Iteration: 84 0.03204178810119629 opened=True
Iteration: 85 0.030735492706298828 opened=True
Iteration: 86 0.03197765350341797 opened=True
Iteration: 87 0.03258228302001953 opened=True
Iteration: 88 0.03184676170349121 opened=True
Iteration: 89 0.03609514236450195 opened=True
Iteration: 90 0.030415058135986328 opened=True
Iteration: 91 0.034477949142456055 opened=True
Iteration: 92 0.033795833587646484 opened=True
Iteration: 93 0.03771209716796875 opened=True
Iteration: 94 0.039679527282714844 opened=True
Iteration: 95 0.03821539878845215 opened=True
Iteration: 96 0.03083968162536621 opened=True
Iteration: 97 0.03497648239135742 opened=True
Iteration: 98 0.030935049057006836 opened=True
Iteration: 99 0.0334165096282959 opened=True

test_openHeadless.zip (17.4 KB)

1 Like

Thanks for your reply, it also works on my end. I will try using your script as a base for mine and see if I can fix mine like this. Probably something wrong on my other script

1 Like

Thanks for looking into this. I don’t think 100 iterations is enough to test this. Using your code and a .3dm file with just a nurbs sphere in it:

Iteration: 509 0.06582403182983398 opened=True
Iteration: 510 0.07779264450073242 opened=True
Iteration: 511 0.06682157516479492 opened=True
Iteration: 512 0.0797872543334961 opened=True
Iteration: 513 0.08078360557556152 opened=True
Iteration: 514 0.07280540466308594 opened=True
Iteration: 515 0.06682109832763672 opened=True
Iteration: 516 0.0747990608215332 opened=True
Iteration: 517 0.07746767997741699 opened=True
Iteration: 518 0.07480120658874512 opened=True
Iteration: 519 0.07878923416137695 opened=True
Iteration: 520 0.07779264450073242 opened=True
Iteration: 521 0.07878899574279785 opened=True
Iteration: 522 0.08676624298095703 opened=True
Iteration: 523 0.0658257007598877 opened=True
Iteration: 524 0.06881856918334961 opened=True
Iteration: 525 0.0688161849975586 opened=True
Iteration: 526 0.07480049133300781 opened=True
Iteration: 527 0.07480001449584961 opened=True
Iteration: 528 0.07978487014770508 opened=True
Iteration: 529 0.07480192184448242 opened=True
Iteration: 530 0.07579684257507324 opened=True
Iteration: 531 0.09275221824645996 opened=True
Iteration: 532 0.09275126457214355 opened=True
Iteration: 533 0.07380199432373047 opened=True
Iteration: 534 0.0718085765838623 opened=True
Iteration: 535 0.07480025291442871 opened=True
Iteration: 536 0.08776473999023438 opened=True
Iteration: 537 0.08377575874328613 opened=True
Iteration: 538 0.07380270957946777 opened=True
Iteration: 539 0.0718083381652832 opened=True
Iteration: 540 0.06881570816040039 opened=True
Iteration: 541 0.08278131484985352 opened=True
Iteration: 542 0.07878947257995605 opened=True
Iteration: 543 0.07280492782592773 opened=True
Iteration: 544 0.07579755783081055 opened=True
Iteration: 545 0.0857703685760498 opened=True
Iteration: 546 0.08078217506408691 opened=True
Iteration: 547 0.08377695083618164 opened=True
Iteration: 548 0.08676815032958984 opened=True
Iteration: 549 0.07679510116577148 opened=True
Iteration: 550 0.08876228332519531 opened=True
Iteration: 551 0.09275245666503906 opened=True
Iteration: 552 0.07878923416137695 opened=True
Iteration: 553 0.0967402458190918 opened=True
Iteration: 554 0.07779169082641602 opened=True
Iteration: 555 0.08377528190612793 opened=True
Iteration: 556 0.08577084541320801 opened=True
Iteration: 557 0.08078432083129883 opened=True
Iteration: 558 0.08078312873840332 opened=True
Iteration: 559 0.07779049873352051 opened=True
Iteration: 560 0.08477497100830078 opened=True
Iteration: 561 0.07978653907775879 opened=True
Iteration: 562 0.07280564308166504 opened=True
Iteration: 563 0.07480001449584961 opened=True
Iteration: 564 0.06881499290466309 opened=True
Iteration: 565 0.07380247116088867 opened=True
Iteration: 566 0.08477258682250977 opened=True
Iteration: 567 0.11469602584838867 opened=True
Iteration: 568 0.0827782154083252 opened=True
Iteration: 569 0.0747990608215332 opened=True
Iteration: 570 0.09574389457702637 opened=True
Iteration: 571 0.08477306365966797 opened=True
Iteration: 572 0.07779240608215332 opened=True
Iteration: 573 0.09474921226501465 opened=True
Iteration: 574 0.0827786922454834 opened=True
Iteration: 575 0.10272479057312012 opened=True
Iteration: 576 0.07779240608215332 opened=True
Iteration: 577 0.07978558540344238 opened=True
Iteration: 578 0.08477258682250977 opened=True
Iteration: 579 0.07978653907775879 opened=True
Iteration: 580 0.0937495231628418 opened=True
Iteration: 581 0.09873604774475098 opened=True
Iteration: 582 0.10073089599609375 opened=True
Iteration: 583 0.08676743507385254 opened=True
Iteration: 584 0.09574484825134277 opened=True
Iteration: 585 0.0827782154083252 opened=True
Iteration: 586 0.0827796459197998 opened=True
Iteration: 587 0.08477377891540527 opened=True
Iteration: 588 0.07480216026306152 opened=True
Iteration: 589 0.07779097557067871 opened=True
Iteration: 590 0.10671520233154297 opened=True
Iteration: 591 0.08677005767822266 opened=True
Iteration: 592 0.0937492847442627 opened=True
Iteration: 593 0.09474945068359375 opened=True
Iteration: 594 0.09275245666503906 opened=True
Iteration: 595 0.09773826599121094 opened=True
Iteration: 596 0.09175586700439453 opened=True
Iteration: 597 0.08377647399902344 opened=True
Iteration: 598 0.08477234840393066 opened=True
Iteration: 599 0.08078169822692871 opened=True
Iteration: 600 0.0907599925994873 opened=True
Iteration: 601 0.09075617790222168 opened=True
Iteration: 602 0.08178138732910156 opened=True
Iteration: 603 0.0827782154083252 opened=True
Iteration: 604 0.09773945808410645 opened=True
Iteration: 605 0.08776593208312988 opened=True
Iteration: 606 0.08776569366455078 opened=True
Iteration: 607 0.11070394515991211 opened=True
Iteration: 608 0.10372281074523926 opened=True
Iteration: 609 0.09175419807434082 opened=True
Iteration: 610 0.0937495231628418 opened=True
Iteration: 611 0.09773874282836914 opened=True
Iteration: 612 0.08178162574768066 opened=True
Iteration: 613 0.1047201156616211 opened=True
Iteration: 614 0.11170148849487305 opened=True
Iteration: 615 0.10671496391296387 opened=True
Iteration: 616 0.10871219635009766 opened=True
Iteration: 617 0.08377599716186523 opened=True
Iteration: 618 0.10571765899658203 opened=True
Iteration: 619 0.09873580932617188 opened=True
Iteration: 620 0.08676815032958984 opened=True
Iteration: 621 0.09374809265136719 opened=True
Iteration: 622 0.09873652458190918 opened=True
Iteration: 623 0.12167739868164062 opened=True
Iteration: 624 0.10671472549438477 opened=True
Iteration: 625 0.0877683162689209 opened=True
Iteration: 626 0.11170196533203125 opened=True
Iteration: 627 0.08876323699951172 opened=True
Iteration: 628 0.08876347541809082 opened=True
Iteration: 629 0.09175515174865723 opened=True
Iteration: 630 0.08477354049682617 opened=True
Iteration: 631 0.10571932792663574 opened=True
Iteration: 632 0.09574627876281738 opened=True
Iteration: 633 0.13164854049682617 opened=True
Iteration: 634 0.11170172691345215 opened=True
Iteration: 635 0.09075760841369629 opened=True
Iteration: 636 0.0967414379119873 opened=True
Iteration: 637 0.11369633674621582 opened=True
Iteration: 638 0.11569333076477051 opened=True
Iteration: 639 0.08676671981811523 opened=True
Iteration: 640 0.09474849700927734 opened=True
Iteration: 641 0.08975934982299805 opened=True
Iteration: 642 0.07978487014770508 opened=True
Iteration: 643 0.13663458824157715 opened=True
Iteration: 644 0.08477306365966797 opened=True
Iteration: 645 0.1107027530670166 opened=True
Iteration: 646 0.09076237678527832 opened=True
Iteration: 647 0.10272574424743652 opened=True
Iteration: 648 0.11170125007629395 opened=True
Iteration: 649 0.10272479057312012 opened=True
Iteration: 650 0.10372281074523926 opened=True
Iteration: 651 0.10870957374572754 opened=True
Iteration: 652 0.09574651718139648 opened=True
Iteration: 653 0.11170148849487305 opened=True
Iteration: 654 0.10771012306213379 opened=True
Iteration: 655 0.10471916198730469 opened=True
Iteration: 656 0.10073089599609375 opened=True
Iteration: 657 0.09574365615844727 opened=True
Iteration: 658 0.09374856948852539 opened=True
Iteration: 659 0.09773755073547363 opened=True
Iteration: 660 0.0907583236694336 opened=True
Iteration: 661 0.12566351890563965 opened=True
Iteration: 662 0.09773826599121094 opened=True
Iteration: 663 0.10073113441467285 opened=True
Iteration: 664 0.11170101165771484 opened=True
Iteration: 665 0.12566423416137695 opened=True
Iteration: 666 0.1266615390777588 opened=True
Iteration: 667 0.1186823844909668 opened=True
Iteration: 668 0.14162325859069824 opened=True
Iteration: 669 0.1296534538269043 opened=True
Iteration: 670 0.0957343578338623 opened=True
Iteration: 671 0.09474658966064453 opened=True
Iteration: 672 0.09574437141418457 opened=True
Iteration: 673 0.10372471809387207 opened=True
Iteration: 674 0.10073113441467285 opened=True
Iteration: 675 0.10771489143371582 opened=True
Iteration: 676 0.10272526741027832 opened=True
Iteration: 677 0.10671544075012207 opened=True
Iteration: 678 0.13364458084106445 opened=True
Iteration: 679 0.10471868515014648 opened=True
Iteration: 680 0.09873604774475098 opened=True
Iteration: 681 0.09574413299560547 opened=True
Iteration: 682 0.09175705909729004 opened=True
Iteration: 683 0.09973335266113281 opened=True
Iteration: 684 0.12067723274230957 opened=True
Iteration: 685 0.09474682807922363 opened=True
Iteration: 686 0.09773874282836914 opened=True
Iteration: 687 0.10671639442443848 opened=True
Iteration: 688 0.11169981956481934 opened=True
Iteration: 689 0.11469602584838867 opened=True
Iteration: 690 0.13663434982299805 opened=True
Iteration: 691 0.11070394515991211 opened=True
Iteration: 692 0.11569094657897949 opened=True
Iteration: 693 0.11369609832763672 opened=True
Iteration: 694 0.10870838165283203 opened=True
Iteration: 695 0.12167525291442871 opened=True
Iteration: 696 0.11070609092712402 opened=True
Iteration: 697 0.09973359107971191 opened=True
Iteration: 698 0.13065195083618164 opened=True
Iteration: 699 0.10970735549926758 opened=True
Iteration: 700 0.10970687866210938 opened=True
Iteration: 701 0.11269831657409668 opened=True
Iteration: 702 0.11469316482543945 opened=True
Iteration: 703 0.11070656776428223 opened=True
Iteration: 704 0.11469292640686035 opened=True
Iteration: 705 0.10172843933105469 opened=True
Iteration: 706 0.10870933532714844 opened=True
Iteration: 707 0.13463902473449707 opened=True
Iteration: 708 0.11967945098876953 opened=True
Iteration: 709 0.1376323699951172 opened=True
Iteration: 710 0.12067961692810059 opened=True
Iteration: 711 0.12366795539855957 opened=True
Iteration: 712 0.151594877243042 opened=True
Iteration: 713 0.11269974708557129 opened=True
Iteration: 714 0.09973573684692383 opened=True
Iteration: 715 0.13763189315795898 opened=True
Iteration: 716 0.11768507957458496 opened=True
Iteration: 717 0.1127011775970459 opened=True
Iteration: 718 0.11768341064453125 opened=True
Iteration: 719 0.10372376441955566 opened=True
Iteration: 720 0.11569070816040039 opened=True
Iteration: 721 0.11269712448120117 opened=True
Iteration: 722 0.11868071556091309 opened=True
Iteration: 723 0.10870957374572754 opened=True
Iteration: 724 0.12067747116088867 opened=True
Iteration: 725 0.12765908241271973 opened=True
Iteration: 726 0.118682861328125 opened=True
Iteration: 727 0.1376326084136963 opened=True
Iteration: 728 0.12466716766357422 opened=True
Iteration: 729 0.12267255783081055 opened=True
Iteration: 730 0.1296558380126953 opened=True
Iteration: 731 0.12167668342590332 opened=True
Iteration: 732 0.1077113151550293 opened=True
Iteration: 733 0.11967921257019043 opened=True
Iteration: 734 0.12366843223571777 opened=True
Iteration: 735 0.1575789451599121 opened=True
Iteration: 736 0.12566208839416504 opened=True
Iteration: 737 0.13364028930664062 opened=True
Iteration: 738 0.112701416015625 opened=True
Iteration: 739 0.13065099716186523 opened=True
Iteration: 740 0.11469197273254395 opened=True
Iteration: 741 0.13962697982788086 opened=True
Iteration: 742 0.1495985984802246 opened=True
Iteration: 743 0.11668801307678223 opened=True
Iteration: 744 0.11768698692321777 opened=True
Iteration: 745 0.12267231941223145 opened=True
Iteration: 746 0.1436161994934082 opened=True
Iteration: 747 0.11568999290466309 opened=True
Iteration: 748 0.14760780334472656 opened=True
Iteration: 749 0.1326446533203125 opened=True
Iteration: 750 0.13962936401367188 opened=True
Iteration: 751 0.14760565757751465 opened=True
Iteration: 752 0.1406240463256836 opened=True
Iteration: 753 0.12965011596679688 opened=True
Iteration: 754 0.13064885139465332 opened=True
Iteration: 755 0.12167477607727051 opened=True
Iteration: 756 0.13364267349243164 opened=True
Iteration: 757 0.1186830997467041 opened=True
Iteration: 758 0.09873509407043457 opened=True
Iteration: 759 0.10272645950317383 opened=True
Iteration: 760 0.10372257232666016 opened=True
Iteration: 761 0.11968040466308594 opened=True
Iteration: 762 0.11070418357849121 opened=True
Iteration: 763 0.1625683307647705 opened=True
Iteration: 764 0.10671472549438477 opened=True
Iteration: 765 0.1077117919921875 opened=True
Iteration: 766 0.10372519493103027 opened=True
Iteration: 767 0.10870695114135742 opened=True
Iteration: 768 0.10372352600097656 opened=True
Iteration: 769 0.10870957374572754 opened=True
Iteration: 770 0.13962602615356445 opened=True
Iteration: 771 0.11469173431396484 opened=True
Iteration: 772 0.11369752883911133 opened=True
Iteration: 773 0.1077122688293457 opened=True
Iteration: 774 0.10870838165283203 opened=True
Iteration: 775 0.09973335266113281 opened=True
Iteration: 776 0.10771369934082031 opened=True
Iteration: 777 0.11369442939758301 opened=True
Iteration: 778 0.11170077323913574 opened=True
Iteration: 779 0.09973430633544922 opened=True
Iteration: 780 0.1077127456665039 opened=True
Iteration: 781 0.10970735549926758 opened=True
Iteration: 782 0.12067699432373047 opened=True
Iteration: 783 0.11369538307189941 opened=True
Iteration: 784 0.11768674850463867 opened=True
Iteration: 785 0.13364124298095703 opened=True
Iteration: 786 0.11768507957458496 opened=True
Iteration: 787 0.10372304916381836 opened=True
Iteration: 788 0.1077120304107666 opened=True
Iteration: 789 0.1047201156616211 opened=True
Iteration: 790 0.1047210693359375 opened=True
Iteration: 791 0.10372257232666016 opened=True
Iteration: 792 0.1077127456665039 opened=True
Iteration: 793 0.10970926284790039 opened=True
Iteration: 794 0.10671401023864746 opened=True
Iteration: 795 0.1406266689300537 opened=True
Iteration: 796 0.1406242847442627 opened=True
Iteration: 797 0.11170125007629395 opened=True
Iteration: 798 0.11269831657409668 opened=True
Iteration: 799 0.1077127456665039 opened=True
Iteration: 800 0.11070466041564941 opened=True
Iteration: 801 0.10472226142883301 opened=True
Iteration: 802 0.1077125072479248 opened=True
Iteration: 803 0.11469221115112305 opened=True
Iteration: 804 0.1077117919921875 opened=True
Iteration: 805 0.12865614891052246 opened=True
Iteration: 806 0.10970687866210938 opened=True
Iteration: 807 0.12067985534667969 opened=True
Iteration: 808 0.11170172691345215 opened=True
Iteration: 809 0.11469364166259766 opened=True
Iteration: 810 0.12366938591003418 opened=True
Iteration: 811 0.13065123558044434 opened=True
Iteration: 812 0.1326453685760498 opened=True
Iteration: 813 0.11469578742980957 opened=True
Iteration: 814 0.11668944358825684 opened=True
Iteration: 815 0.12765908241271973 opened=True
Iteration: 816 0.11968040466308594 opened=True
Iteration: 817 0.13164830207824707 opened=True
Iteration: 818 0.1186830997467041 opened=True
Iteration: 819 0.12167739868164062 opened=True
Iteration: 820 0.12366962432861328 opened=True
Iteration: 821 0.1266617774963379 opened=True
Iteration: 822 0.12366914749145508 opened=True
Iteration: 823 0.11967802047729492 opened=True
Iteration: 824 0.12167501449584961 opened=True
Iteration: 825 0.13065099716186523 opened=True
Iteration: 826 0.12865543365478516 opened=True
Iteration: 827 0.118682861328125 opened=True
Iteration: 828 0.12267160415649414 opened=True
Iteration: 829 0.11568903923034668 opened=True
Iteration: 830 0.11768531799316406 opened=True
Iteration: 831 0.11868572235107422 opened=True
Iteration: 832 0.12267208099365234 opened=True
Iteration: 833 0.1186819076538086 opened=True
Iteration: 834 0.12566232681274414 opened=True
Iteration: 835 0.1296534538269043 opened=True
Iteration: 836 0.12466740608215332 opened=True
Iteration: 837 0.12665987014770508 opened=True
Iteration: 838 0.13563776016235352 opened=True
Iteration: 839 0.12466692924499512 opened=True
Iteration: 840 0.13463759422302246 opened=True
Iteration: 841 0.12566614151000977 opened=True
Iteration: 842 0.1296520233154297 opened=True
Iteration: 843 0.11768412590026855 opened=True
Iteration: 844 0.1236720085144043 opened=True
Iteration: 845 0.1186830997467041 opened=True
Iteration: 846 0.11668825149536133 opened=True
Iteration: 847 0.13134360313415527 opened=True
Iteration: 848 0.1186833381652832 opened=True
Iteration: 849 0.1236717700958252 opened=True
Iteration: 850 0.14561033248901367 opened=True
Iteration: 851 0.12366962432861328 opened=True
Iteration: 852 0.12865614891052246 opened=True
Iteration: 853 0.1296536922454834 opened=True
Iteration: 854 0.12267255783081055 opened=True
Iteration: 855 0.12865614891052246 opened=True
Iteration: 856 0.12366962432861328 opened=True
Iteration: 857 0.1376323699951172 opened=True
Iteration: 858 0.12067580223083496 opened=True
Iteration: 859 0.12267303466796875 opened=True
Iteration: 860 0.12765884399414062 opened=True
Iteration: 861 0.11968278884887695 opened=True
Iteration: 862 0.12177610397338867 opened=True
Iteration: 863 0.1266613006591797 opened=True
Iteration: 864 0.12267255783081055 opened=True
Iteration: 865 0.12566423416137695 opened=True
Iteration: 866 0.14860296249389648 opened=True
Iteration: 867 0.12765908241271973 opened=True
Iteration: 868 0.12865638732910156 opened=True
Iteration: 869 0.1436150074005127 opened=True
Iteration: 870 0.13065004348754883 opened=True
Iteration: 871 0.1296534538269043 opened=True
Iteration: 872 0.14162135124206543 opened=True
Iteration: 873 0.13463950157165527 opened=True
Iteration: 874 0.13663458824157715 opened=True
Iteration: 875 0.12965607643127441 opened=True
Iteration: 876 0.14461398124694824 opened=True
Iteration: 877 0.12865614891052246 opened=True
Iteration: 878 0.1326456069946289 opened=True
Iteration: 879 0.13463973999023438 opened=True
Iteration: 880 0.12865591049194336 opened=True
Iteration: 881 0.12865686416625977 opened=True
Iteration: 882 0.1266613006591797 opened=True
Iteration: 883 0.1386277675628662 opened=True
Iteration: 884 0.13763213157653809 opened=True
Iteration: 885 0.13763189315795898 opened=True
Iteration: 886 0.13663697242736816 opened=True
Iteration: 887 0.1326453685760498 opened=True
Iteration: 888 0.132645845413208 opened=True
Iteration: 889 0.1515951156616211 opened=True
Iteration: 890 0.1326456069946289 opened=True
Iteration: 891 0.13663649559020996 opened=True
Iteration: 892 0.12765908241271973 opened=True
Iteration: 893 0.13962650299072266 opened=True
Iteration: 894 0.15857601165771484 opened=True
Iteration: 895 0.13364481925964355 opened=True
Iteration: 896 0.12865614891052246 opened=True
Iteration: 897 0.14162373542785645 opened=True
Iteration: 898 0.1356348991394043 opened=True
Iteration: 899 0.16156935691833496 opened=True
Iteration: 900 0.14960002899169922 opened=True
Iteration: 901 0.14162135124206543 opened=True
Iteration: 902 0.13164806365966797 opened=True
Iteration: 903 0.14262127876281738 opened=True
Iteration: 904 0.1436164379119873 opened=True
Iteration: 905 0.13663530349731445 opened=True
Iteration: 906 0.1406266689300537 opened=True
Iteration: 907 0.13464021682739258 opened=True
Iteration: 908 0.1515941619873047 opened=True
Iteration: 909 0.15957331657409668 opened=True
Iteration: 910 0.14162135124206543 opened=True
Iteration: 911 0.1466073989868164 opened=True
Iteration: 912 0.13264799118041992 opened=True
Iteration: 913 0.13663482666015625 opened=True
Iteration: 914 0.14262008666992188 opened=True
Iteration: 915 0.13663506507873535 opened=True
Iteration: 916 0.13962674140930176 opened=True
Iteration: 917 0.14461326599121094 opened=True
Iteration: 918 0.1406235694885254 opened=True
Iteration: 919 0.13862991333007812 opened=True
Iteration: 920 0.14261913299560547 opened=True
Iteration: 921 0.13862967491149902 opened=True
Iteration: 922 0.15558409690856934 opened=True
Iteration: 923 0.15658116340637207 opened=True
Iteration: 924 0.14461326599121094 opened=True
Iteration: 925 0.17154407501220703 opened=True
Iteration: 926 0.14261722564697266 opened=True
Iteration: 927 0.14561104774475098 opened=True
Iteration: 928 0.1466081142425537 opened=True
Iteration: 929 0.14261913299560547 opened=True
Iteration: 930 0.17054438591003418 opened=True
Iteration: 931 0.1595757007598877 opened=True
Iteration: 932 0.162567138671875 opened=True
Iteration: 933 0.1466052532196045 opened=True
Iteration: 934 0.15059661865234375 opened=True
Iteration: 935 0.1436152458190918 opened=True
Iteration: 936 0.14461278915405273 opened=True
Iteration: 937 0.1486043930053711 opened=True
Iteration: 938 0.14261579513549805 opened=True
Iteration: 939 0.14461255073547363 opened=True
Iteration: 940 0.14261770248413086 opened=True
Iteration: 941 0.15059447288513184 opened=True
Iteration: 942 0.15159106254577637 opened=True
Iteration: 943 0.1515974998474121 opened=True
Iteration: 944 1.5075290203094482 opened=True
Iteration: 945 0.16256189346313477 opened=True
Iteration: 946 0.16356539726257324 opened=True
Iteration: 947 0.17253780364990234 opened=True
Iteration: 948 0.15857458114624023 opened=True
Iteration: 949 0.16057109832763672 opened=True
Iteration: 950 0.1655564308166504 opened=True
Iteration: 951 0.1845078468322754 opened=True
Iteration: 952 0.1665513515472412 opened=True
Iteration: 953 0.17054486274719238 opened=True
Iteration: 954 0.17453265190124512 opened=True
Iteration: 955 0.17552900314331055 opened=True
Iteration: 956 0.1655585765838623 opened=True
Iteration: 957 0.16755151748657227 opened=True
Iteration: 958 0.16455841064453125 opened=True
Iteration: 959 0.16555452346801758 opened=True
Iteration: 960 0.18350982666015625 opened=True
Iteration: 961 0.17353558540344238 opened=True
Iteration: 962 0.19148635864257812 opened=True
Iteration: 963 0.17453408241271973 opened=True
Iteration: 964 0.1825110912322998 opened=True
Iteration: 965 0.18350863456726074 opened=True
Iteration: 966 0.176527738571167 opened=True
Iteration: 967 0.16156792640686035 opened=True
Iteration: 968 0.17852091789245605 opened=True
Iteration: 969 0.17054295539855957 opened=True
Iteration: 970 0.1795186996459961 opened=True
Iteration: 971 0.16256356239318848 opened=True
Iteration: 972 0.18450617790222168 opened=True
Iteration: 973 0.19547343254089355 opened=True
Iteration: 974 0.20445036888122559 opened=True
Iteration: 975 0.2014613151550293 opened=True
Iteration: 976 0.1775226593017578 opened=True
Iteration: 977 0.1765272617340088 opened=True
Iteration: 978 0.1825101375579834 opened=True
Iteration: 979 0.1855003833770752 opened=True
Iteration: 980 0.1765294075012207 opened=True
Iteration: 981 0.21442556381225586 opened=True
Iteration: 982 0.1884927749633789 opened=True
Iteration: 983 0.218414306640625 opened=True
Iteration: 984 0.20644927024841309 opened=True
Iteration: 985 0.16356134414672852 opened=True
Iteration: 986 0.16356515884399414 opened=True
Iteration: 987 0.17353510856628418 opened=True
Iteration: 988 0.18450355529785156 opened=True
Iteration: 989 0.16455960273742676 opened=True
Iteration: 990 0.1685478687286377 opened=True
Iteration: 991 0.1745305061340332 opened=True
Iteration: 992 0.18749785423278809 opened=True
Iteration: 993 0.17353510856628418 opened=True
Iteration: 994 0.16456151008605957 opened=True
Iteration: 995 0.17253613471984863 opened=True
Iteration: 996 0.16555500030517578 opened=True
Iteration: 997 0.17054390907287598 opened=True
Iteration: 998 0.16455936431884766 opened=True
Iteration: 999 0.16954874992370605 opened=True

Running it again results in similar times as the last iterations of the first run:

Iteration: 997 0.17054390907287598 opened=True
Iteration: 998 0.16455936431884766 opened=True
Iteration: 999 0.16954874992370605 opened=True
Iteration: 0 0.2972099781036377 opened=True
Iteration: 1 0.19348669052124023 opened=True
Iteration: 2 0.2094411849975586 opened=True
Iteration: 3 0.19448256492614746 opened=True
Iteration: 4 0.2124326229095459 opened=True
Iteration: 5 0.21741867065429688 opened=True
Iteration: 6 0.207442045211792 opened=True
Iteration: 7 0.18949484825134277 opened=True
Iteration: 8 0.18949508666992188 opened=True
Iteration: 9 0.1845083236694336 opened=True
Iteration: 10 0.1874997615814209 opened=True

This is py3 on Rhino 8.5

1 Like

Ok this is good! I’ll investigate. Thank you!

Ok I filed this issue and will get input from team to see where the problem is

RH-81342 OpenHeadless gets progressively slow

2 Likes

Hi,
With a lot of files I also experience the same issue. @eirannejad any news on this ? It’s quite important for us. Here is my output log (I added time information for opening the file)

Exported C:\Users\loicg\geomill_temp_files\41887.gltf Iteration 0 opened=True in 1.8956573009490967s, total : 1.9176533222198486s
Exported C:\Users\loicg\geomill_temp_files\41886.gltf Iteration 1 opened=True in 0.1691133975982666s, total : 0.19026684761047363s
Exported C:\Users\loicg\geomill_temp_files\41885.gltf Iteration 2 opened=True in 0.19170761108398438s, total : 0.21267104148864746s
Exported C:\Users\loicg\geomill_temp_files\41884.gltf Iteration 3 opened=True in 0.23329544067382812s, total : 0.2540161609649658s
Exported C:\Users\loicg\geomill_temp_files\41883.gltf Iteration 4 opened=True in 0.17435002326965332s, total : 0.19799423217773438s
Exported C:\Users\loicg\geomill_temp_files\41882.gltf Iteration 5 opened=True in 0.20513534545898438s, total : 0.2671365737915039s
Exported C:\Users\loicg\geomill_temp_files\41881.gltf Iteration 6 opened=True in 0.24000120162963867s, total : 0.26399946212768555s
Exported C:\Users\loicg\geomill_temp_files\41847.gltf Iteration 7 opened=True in 0.20113539695739746s, total : 0.22763586044311523s
Exported C:\Users\loicg\geomill_temp_files\41846.gltf Iteration 8 opened=True in 0.26110124588012695s, total : 0.30609130859375s
Exported C:\Users\loicg\geomill_temp_files\41880.gltf Iteration 9 opened=True in 0.2818615436553955s, total : 0.30881667137145996s
Exported C:\Users\loicg\geomill_temp_files\41879.gltf Iteration 10 opened=True in 0.22298574447631836s, total : 0.24763846397399902s
Exported C:\Users\loicg\geomill_temp_files\41878.gltf Iteration 11 opened=True in 0.2081141471862793s, total : 0.23011422157287598s
Exported C:\Users\loicg\geomill_temp_files\41830.gltf Iteration 12 opened=True in 0.20585203170776367s, total : 0.2428750991821289s
Exported C:\Users\loicg\geomill_temp_files\41827.gltf Iteration 13 opened=True in 0.19064545631408691s, total : 0.21334385871887207s
Exported C:\Users\loicg\geomill_temp_files\41819.gltf Iteration 14 opened=True in 0.20859408378601074s, total : 0.237595796585083s
Exported C:\Users\loicg\geomill_temp_files\41807.gltf Iteration 15 opened=True in 0.2230229377746582s, total : 0.2490229606628418s
Exported C:\Users\loicg\geomill_temp_files\41798.gltf Iteration 16 opened=True in 0.1918654441833496s, total : 0.21387577056884766s
Exported C:\Users\loicg\geomill_temp_files\41877.gltf Iteration 17 opened=True in 0.17009234428405762s, total : 0.19030451774597168s
Exported C:\Users\loicg\geomill_temp_files\41876.gltf Iteration 18 opened=True in 0.19418907165527344s, total : 0.22816920280456543s
Exported C:\Users\loicg\geomill_temp_files\41875.gltf Iteration 19 opened=True in 0.23900461196899414s, total : 0.27478814125061035s
Exported C:\Users\loicg\geomill_temp_files\41874.gltf Iteration 20 opened=True in 0.232468843460083s, total : 0.32002782821655273s
Exported C:\Users\loicg\geomill_temp_files\41873.gltf Iteration 21 opened=True in 0.20055866241455078s, total : 0.22057843208312988s
Exported C:\Users\loicg\geomill_temp_files\41872.gltf Iteration 22 opened=True in 0.1912527084350586s, total : 0.2133331298828125s
Exported C:\Users\loicg\geomill_temp_files\41871.gltf Iteration 23 opened=True in 0.21716547012329102s, total : 0.23817086219787598s
Exported C:\Users\loicg\geomill_temp_files\41870.gltf Iteration 24 opened=True in 0.18969964981079102s, total : 0.21869778633117676s
Exported C:\Users\loicg\geomill_temp_files\41869.gltf Iteration 25 opened=True in 0.17700839042663574s, total : 0.19696426391601562s
Exported C:\Users\loicg\geomill_temp_files\41868.gltf Iteration 26 opened=True in 0.1701498031616211s, total : 0.18856382369995117s
Exported C:\Users\loicg\geomill_temp_files\41867.gltf Iteration 27 opened=True in 0.16227364540100098s, total : 0.1883249282836914s
Exported C:\Users\loicg\geomill_temp_files\41866.gltf Iteration 28 opened=True in 0.17594361305236816s, total : 0.1990053653717041s
Exported C:\Users\loicg\geomill_temp_files\41865.gltf Iteration 29 opened=True in 0.22813057899475098s, total : 0.2511308193206787s
Exported C:\Users\loicg\geomill_temp_files\41864.gltf Iteration 30 opened=True in 0.19602322578430176s, total : 0.2309858798980713s
...
Exported C:\Users\loicg\geomill_temp_files\42052.gltf Iteration 532 opened=True in 1.0334393978118896s, total : 1.0612361431121826s
Exported C:\Users\loicg\geomill_temp_files\42051.gltf Iteration 533 opened=True in 1.0810620784759521s, total : 1.1060950756072998s
Exported C:\Users\loicg\geomill_temp_files\42050.gltf Iteration 534 opened=True in 1.1369562149047852s, total : 1.1660888195037842s
Exported C:\Users\loicg\geomill_temp_files\42049.gltf Iteration 535 opened=True in 1.1469354629516602s, total : 1.1679110527038574s
Exported C:\Users\loicg\geomill_temp_files\42048.gltf Iteration 536 opened=True in 1.5522980690002441s, total : 1.5917160511016846s
Exported C:\Users\loicg\geomill_temp_files\42047.gltf Iteration 537 opened=True in 1.8277180194854736s, total : 1.8748047351837158s
Exported C:\Users\loicg\geomill_temp_files\42046.gltf Iteration 538 opened=True in 1.674370288848877s, total : 1.6964311599731445s
Exported C:\Users\loicg\geomill_temp_files\42044.gltf Iteration 539 opened=True in 1.43300461769104s, total : 1.456005573272705s
Exported C:\Users\loicg\geomill_temp_files\42045.gltf Iteration 540 opened=True in 1.1895942687988281s, total : 1.2080893516540527s
Exported C:\Users\loicg\geomill_temp_files\42043.gltf Iteration 541 opened=True in 1.367720127105713s, total : 1.3956351280212402s
Exported C:\Users\loicg\geomill_temp_files\42042.gltf Iteration 542 opened=True in 1.4251000881195068s, total : 1.4542620182037354s
Exported C:\Users\loicg\geomill_temp_files\42041.gltf Iteration 543 opened=True in 1.3778932094573975s, total : 1.3998639583587646s
Exported C:\Users\loicg\geomill_temp_files\42040.gltf Iteration 544 opened=True in 1.1881380081176758s, total : 1.2771377563476562s
#! python 3
import scriptcontext as sc
import Rhino
import time
from datetime import datetime

options = Rhino.FileIO.FileGltfWriteOptions()
options.UseDisplayColorForUnsetMaterials = False
options.MapZToY = True
exported_files = []
if enabled is not None:
    if enabled is not False:
        if done is not None:
            for i,source in enumerate(sources):
                start = time.time()
                doc = Rhino.RhinoDoc.OpenHeadless(source)
                opened = doc is not None
                if opened:
                    opening_time = time.time()
                    Rhino.FileIO.FileGltf.Write(destinations[i],doc,options)
                    exported_files.append(destinations[i])
                    doc.Dispose()
                    end = time.time()
                    print(f"Exported {destinations[i]} Iteration {i} {opened=} in {opening_time - start}s, total : {end - start}s")
            

In case it can help to solve the issue. Maybe it is linked to this:

Hi Johan,

Yes, it could be related. The GLTF exporter I am using is actually a python script running in a cluster.
Not sure what’s the exact reason behind all of this, but they look like similar issues.

I will experiment today with this exporter, perhaps by running that over compute. Maybe I will find out something ?

1 Like

Hi @AndyPayne, maybe you could take a look at it ?
In general, I am trying to run a “3dm to gltf exporter” over compute, with support for gltf export options, such as DracoCompressionLevel, Or MapZtoY, and keeping colors from 3dm to gltf.
So far the plugins I’ve tried (Pancake’s Export To, ) were not working on compute, I was not able to use them.
I have the python script above, clustered, but it’s heavily slowing down after a few hundreds of assets (I have 6000 to export, the firs 2000 take 1h, the rest start taking days.)
Running this cluster on compute as mentioned upper does not work, somehow the gltf Write function returns False. Hard to tell why in details…
I attach the compute script with the internalized hops definition, the definition itself, and 3 sample .3dm files I was using to test. Just feed it with the list of the 3dm sources. If you can find the reason of the unsuccessful export on compute, that would help a lot. Thanks in advance.

39778.3dm (8.1 KB)
39779.3dm (8.1 KB)
39780.3dm (8.1 KB)
export_gltf_compute.gh (12.0 KB)
caller.gh (15.4 KB)

EDIT : Uploaded the wrong file, fixed

EDIT 2:
Just to illustrate this issue, here is my script using twice the exporter, to generate all assets as gltf, and again all assets as glb. Notice the time it takes, the glb exporter is running after the gltf when grasshopper resolves the definition.

Thanks for reporting this. Yes, I can have a look. I believe we had another customer who recently reported a similar issue with gltf import/export… so I think these two issue may be related. I’ll have a look and create a YT if necessary.

1 Like

Thanks a lot.

Here another topic that may be related :

Clusters is not freeing up RAM? - Grasshopper - McNeel Forum

2 Likes

This is the one I was thinking. RhinoCompute Importing Broken in 8.6 - #6 by Tai

Hi Andy,

Sorry for pinging again, but I wanted to know if there were maybe some news on this ?
Thanks and have a good week

@Laoky Hi. I think this is the same problem as:

RH-81342 OpenHeadless gets progressively slow

We put a fix for this in Rhino 8.8 which should be on Release candidate this week. Would you mind testing that?

2 Likes

With pleasure !

1 Like