| 751 | } |
| 752 | |
| 753 | void |
| 754 | Arena::Finalize () |
| 755 | { |
| 756 | #ifdef AMREX_USE_GPU |
| 757 | if (amrex::Verbose() > 0) { |
| 758 | #else |
| 759 | if (amrex::Verbose() > 1) { |
| 760 | #endif |
| 761 | PrintUsage(true); |
| 762 | } |
| 763 | |
| 764 | initialized = false; |
| 765 | |
| 766 | // we reset Arenas unless they are the default "CPU malloc/free" BArena |
| 767 | // this is because we want to allow users to free their UB objects |
| 768 | // that they forgot to destruct after amrex::Finalize(): |
| 769 | // amrex::Initialize(...); |
| 770 | // MultiFab mf(...); // this should be scoped in { ... } |
| 771 | // amrex::Finalize(); |
| 772 | // mf cannot be used now, but it can at least be freed without a segfault |
| 773 | if (!dynamic_cast<BArena*>(the_comms_arena)) { |
| 774 | if (the_comms_arena != the_device_arena && the_comms_arena != the_pinned_arena) { |
| 775 | delete the_comms_arena; |
| 776 | } |
| 777 | the_comms_arena = nullptr; |
| 778 | } |
| 779 | |
| 780 | if (!dynamic_cast<BArena*>(the_device_arena)) { |
| 781 | if (the_device_arena != the_arena) { |
| 782 | delete the_device_arena; |
| 783 | } |
| 784 | the_device_arena = nullptr; |
| 785 | } |
| 786 | |
| 787 | if (!dynamic_cast<BArena*>(the_managed_arena)) { |
| 788 | if (the_managed_arena != the_arena) { |
| 789 | delete the_managed_arena; |
| 790 | } |
| 791 | the_managed_arena = nullptr; |
| 792 | } |
| 793 | |
| 794 | if (!dynamic_cast<BArena*>(the_arena)) { |
| 795 | delete the_arena; |
| 796 | the_arena = nullptr; |
| 797 | } |
| 798 | |
| 799 | delete the_async_arena; |
| 800 | the_async_arena = nullptr; |
| 801 | |
| 802 | delete the_pinned_arena; |
| 803 | the_pinned_arena = nullptr; |
| 804 | |
| 805 | if (!dynamic_cast<BArena*>(the_cpu_arena)) { |
| 806 | delete the_cpu_arena; |
| 807 | the_cpu_arena = nullptr; |
| 808 | } |
| 809 | |
| 810 | The_BArena()->deregisterFromProfiling(); |
nothing calls this directly
no test coverage detected