Skip to content

Commit

Permalink
DTIO: Update to allow app the opportunity to clean up any data associ…
Browse files Browse the repository at this point in the history
…ated with a Region to prevent memory leaks

This happens when the Region is reset on a topology change
  • Loading branch information
tokusanya committed Nov 14, 2024
1 parent 7ae62fe commit 90c6a57
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,11 @@ namespace Ioss {

void DynamicTopologyObserver::define_transient() {}

void DynamicTopologyObserver::initialize_region()
{
if (nullptr != m_region) {
m_region->reset_region();
}
}

} // namespace Ioss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ namespace Ioss {

virtual bool needs_new_output_file() const;

virtual void initialize_region();

protected:
Region *m_region{nullptr};
unsigned int m_topologyModification{TOPOLOGY_SAME};
Expand Down
20 changes: 16 additions & 4 deletions packages/seacas/libraries/ioss/src/Ioss_Region.C
Original file line number Diff line number Diff line change
Expand Up @@ -2897,7 +2897,8 @@ namespace Ioss {

state++; // For the state we are going to write.

reset_region();
topologyObserver->initialize_region();

DynamicTopologyFileControl fileControl(this);
fileControl.add_output_database_change_set(state);

Expand Down Expand Up @@ -2939,7 +2940,8 @@ namespace Ioss {

state++; // For the state we are going to write.

reset_region();
topologyObserver->initialize_region();

DynamicTopologyFileControl fileControl(this);
fileControl.clone_and_replace_output_database(state);

Expand Down Expand Up @@ -2982,7 +2984,12 @@ namespace Ioss {
if (!iodatabase->open_internal_change_set(set_name))
return false;

reset_region();
if(topologyObserver) {
topologyObserver->initialize_region();
} else {
reset_region();
}

iodatabase->release_memory();

Region::set_state(STATE_CLOSED);
Expand Down Expand Up @@ -3012,7 +3019,12 @@ namespace Ioss {
if (!iodatabase->open_internal_change_set(child_group_index))
return false;

reset_region();
if(topologyObserver) {
topologyObserver->initialize_region();
} else {
reset_region();
}

iodatabase->release_memory();

Region::set_state(STATE_CLOSED);
Expand Down
1 change: 1 addition & 0 deletions packages/seacas/libraries/ioss/src/Ioss_Region.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ namespace Ioss {

IOSS_NODISCARD std::tuple<std::string, int, double> locate_db_state(double targetTime) const;

// Reinitialize region data structures
void reset_region();

protected:
Expand Down

0 comments on commit 90c6a57

Please sign in to comment.