Saving Large PDF runs out of memory

Hi,
I have a 4700 page PDF document and I am trying to convert it to grayscale and saving it (prefer back to source, but can use a different target file) and it seems after about 3000 pages, it runs out of memory.
Is there a away to save to a PDF in blocks of pages (~100) and then release the saved pages from memory ?

Here is a code snipped that I am using:

using (var source = new Document(sourceStream))
{
using(var target = new Document())
{
foreach (var page in source.Pages)
{
var strategy = new RgbToDeviceGrayConversionStrategy();
strategy.Convert(page);
target.Pages.Add(page);
}
target.Save(targetFileName);
}
}

Thanks

@reisvm

Thank you for contacting support.

Would you please share your source file via Google Drive, Dropbox, etc. so that we may try to reproduce and investigate it in our environment. Before sharing requested data, please ensure using Aspose.PDF for .NET 19.10.