From 3838258a57e22c0cf507c6b96eac6a5d99d2a10f Mon Sep 17 00:00:00 2001 From: Abhishek Pandey Date: Wed, 6 Dec 2023 17:10:55 -0800 Subject: [PATCH] Remove graph sdk store references in url cache item map (#4800) Use `Clone()` on item properties so that we don't hold on to graph in-memory store references. --- #### Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [x] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Supportability/Tests - [ ] :computer: CI/Deployment - [x] :broom: Tech Debt/Cleanup #### Issue(s) * # #### Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- src/internal/m365/collection/drive/url_cache.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/internal/m365/collection/drive/url_cache.go b/src/internal/m365/collection/drive/url_cache.go index e89099823..5fb705254 100644 --- a/src/internal/m365/collection/drive/url_cache.go +++ b/src/internal/m365/collection/drive/url_cache.go @@ -2,6 +2,7 @@ package drive import ( "context" + "strings" "sync" "time" @@ -250,10 +251,13 @@ func (uc *urlCache) updateCache( } } - itemID := ptr.Val(item.GetId()) + // Deep copy the item ID and download url so that we don't hold on to + // references to these strings in graph in-memory stores, which can + // take up more memory than necessary. + itemID := strings.Clone(ptr.Val(item.GetId())) uc.idToProps[itemID] = itemProps{ - downloadURL: url, + downloadURL: strings.Clone(url), isDeleted: false, }