For reference read: https://nextjs.org/docs/app/guides/memory-usage and try the mentioned techniques.