Home  >  Q&A  >  body text

Solution to the memory usage problem caused by upsertMany in Nest.js

<p>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? </p> <p>Using nestjs, @mikro-orm/nestjs</p> <pre class="brush:php;toolbar:false;">this.emBi.upsertMany(SingleOrderSales, saveArry)</pre>
P粉787806024P粉787806024453 days ago613

reply all(1)I'll reply

  • P粉798010441

    P粉7980104412023-08-16 09:56:20

    According to the official documentation 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:

    reply
    0
  • Cancelreply