Skip to content

Commit 4f494fa

Browse files
committed
Clear lookup cache after normalization/denormalization to save on memory.
1 parent 1008319 commit 4f494fa

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/DoctrineEntityNormalizer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public function normalize(
6565
return parent::normalize($data, $format, $context);
6666
} finally {
6767
$this->typeExtractor->setCurrentContext();
68+
$this->typeExtractor->clearReflectionClassLookup();
6869
}
6970
}
7071

@@ -88,6 +89,7 @@ public function denormalize(mixed $data, string $type, ?string $format = null, a
8889
return parent::denormalize($data, $type, $format, $context);
8990
} finally {
9091
$this->typeExtractor->setCurrentContext();
92+
$this->typeExtractor->clearReflectionClassLookup();
9193
}
9294
}
9395

src/TypeExtractor/EntityTypeExtractor.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,9 @@ public function getReflectionClass(
210210

211211
return $this->reflClassLookup[$class];
212212
}
213+
214+
public function clearReflectionClassLookup(): void
215+
{
216+
$this->reflClassLookup = [];
217+
}
213218
}

0 commit comments

Comments
 (0)