Skip to content

Heap outage when creating email messages as JSON #1437

@malee1975

Description

@malee1975

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.

Image

The first set of data is from when the mail class is used the second from when the email messages are JSON.

Image

The above flame chart shows the memory allocation for deepClone when using JSON

Image

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions