Solution to the memory usage problem caused by upsertMany in Nest.js
P粉787806024
P粉787806024 2023-08-15 23:04:41
0
1
513

There is a scheduled task that is executed every 5 minutes when using upsertMany to insert a large amount of data. I found that the memory increases every time a task is executed and the GC cannot reclaim the memory. How can I solve this problem?

Using nestjs, @mikro-orm/nestjs

this.emBi.upsertMany(SingleOrderSales, saveArry)
P粉787806024
P粉787806024

reply all (1)
P粉798010441

According to the officialdocumentation https://mikro-orm.io/docs/entity-manager, it seems that you need to manually execute the refresh command after finishing the work with the entity manager (also don't forget to wait). In your case:

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!