-
Notifications
You must be signed in to change notification settings - Fork 783
Description
This is just a bit of research that I have been conducting into the SendGrid API and heap usage. It appears that in circumstances where the email to be sent is constructed as an object heap usage, where there are multiple attachments of varying size, grows in size that rapidly that scavenge and mark-sweep operations struggle to clear the heap used before the heap total exceeds the allocated heap size.
This is in circumstances where 40 emails are sent as a single batch.
Using the new Mail() class and its setters to define the email message allows for a process in the API that uses a deep clone and to camel case function to be removed from the process. The heap issue seems to relate to the fact that the entire email message and its attachments is passed through to the cloning and ultimately to camel case functions (I think!).
Anyway this query is one that suggests a documentation change, maybe one that illustrates more clearly how to use the new Mail() class if users are not personalizing. Anyway some stats from node-red's diagnostics API and some useful screenshots taken with clinic JS.
The first set of data is from when the mail class is used the second from when the email messages are JSON.
The above flame chart shows the memory allocation for deepClone when using JSON
This one when the mail class is used.
The saving in heap I found under the circumstances I tested in can be up to 1GB. Mostly due to mark-sweep being able to mark objects as white more easily and then free up memory.
Just thought this analysis might help...


