Home Javascript memory heap issue on permutating two big array in node js
Reply: 0

Javascript memory heap issue on permutating two big array in node js

user1707
1#
user1707 Published in April 22, 2018, 4:58 am
var array1=[{
                product_code:"test1",
                series:"11w"
            },
            {
                product_code:"test2",
                series:"12w"
            },
            {
                product_code:"test3",
                series:"13w"
            },
            {
                product_code:"test4",
                series:"14w"
            },
            {
                product_code:"test5",
                series:"15w"
            },
            {
                product_code:"test6",
                series:"16w"
            }];

    var array2=[{
                    housing_code:"last_test1",
                    petrize:"swa1"
                },
                {
                    housing_code:"last_test2",
                    petrize:"swa2"
                },
                {
                    housing_code:"last_test3",
                    petrize:"swa3"
                }]

My Code:

        var finalarray=[];
        array1.map((key1,i1)=>{
            array2.map((key2,i2)=>{
                key1['housing_code']=key2.housing_code;
                key1['petrize']=key2.petrize;
                console.log(key1)
                var sw=JSON.stringify(key1);
                finalarray.push(JSON.parse(sw));
            });


        });

This two arrays is just an example. But first array has more than 4500 objects. I have to permutate both array(4500*86) in nodejs. The finalarray gives more than 200 000 records . I have 4GB RAM space I tried node --max-old-space-size=3300 server.js, But it may cause my system hang I also tried npm increase-memory-limit .

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.29938 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO