[VOL-4548] openonuAdapterGo - memory leak seen in long term tests
Change-Id: Ie3eb2048cebf8bf8b2f2a99ccd927d462000223a
diff --git a/internal/pkg/avcfg/onu_uni_tp.go b/internal/pkg/avcfg/onu_uni_tp.go
index efb69be..c51c489 100755
--- a/internal/pkg/avcfg/onu_uni_tp.go
+++ b/internal/pkg/avcfg/onu_uni_tp.go
@@ -1009,3 +1009,14 @@
}
return false
}
+
+// PrepareForGarbageCollection - remove references to prepare for garbage collection
+func (onuTP *OnuUniTechProf) PrepareForGarbageCollection(ctx context.Context, aDeviceID string) {
+ logger.Debugw(ctx, "prepare for garbage collection", log.Fields{"device-id": aDeviceID})
+ onuTP.baseDeviceHandler = nil
+ onuTP.onuDevice = nil
+ for k, v := range onuTP.PAniConfigFsm {
+ v.PrepareForGarbageCollection(ctx, aDeviceID)
+ delete(onuTP.PAniConfigFsm, k)
+ }
+}