Skip to content

High memory usage in 7.0.0 #205

@ahmedmansour-geotab

Description

@ahmedmansour-geotab

NodeJs: v20.17.0
dotnet: 8
Issue: The newest nuget v7.0.0 shows an extremely high memory usage for NodeJs compared to v6.3.1. We ran a stress test on the system and v7.0.0 shows usage 10x the amount v6.3.1 shows.
Expected behaviour: Memory usage should stay the same
Actual behaviour: Memory usage is too high and it blocks us from upgrading to the newest version.

To reproduce the issue, you can run the following snippet against both versions and compare the memory output:

using System.Diagnostics;
using Jering.Javascript.NodeJS;

for (int i = 0; i < 50; i++)
{
    string javascriptModule = @"
module.exports = (callback, x, y) => {  // Module must export a function that takes a callback as its first parameter
    var result = x + y; // Your javascript logic
    callback(null /* If an error occurred, provide an error object or message */, result); // Call the callback when you're done.
}";
    _ = await StaticNodeJSService.InvokeFromStringAsync<int>(javascriptModule, args: new object[] { 3, 5 });
}

Process proc = Process.GetCurrentProcess();
Console.WriteLine("memory = " + proc.PrivateMemorySize64);

Obviously this is a simple repro that doesn't show a 10x increase but it should show a consistently higher value when using 7.0.0 vs 6.3.1

When I run it I get
v7.0.0: 159428608
v6.3.1: 133042176

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