[SERVER-11654] Automatically garbage collect JS Created: 10/Nov/13  Updated: 10/Dec/14  Resolved: 10/Nov/13

Status: Closed
Project: Core Server
Component/s: JavaScript, Shell
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

When connections (Mongo instances in the shell) are null'd they are not automatically garbage collected, as an example. There are probably other examples out there too.

> gc()
> db.serverStatus().connections.current
2
> var m2 = new Mongo()
> db.serverStatus().connections.current
3
> var m2 = null
> db.serverStatus().connections.current
3
> gc()
> db.serverStatus().connections.current
2



 Comments   
Comment by Scott Hernandez (Inactive) [ 11/Nov/13 ]

Something seems wrong if after 2 hours the connection isn't garbage collected and closed, without a manual gc() call.

In node.js and others V8 embedders they use the v8::V8::IdleNotification() call to periodically allow V8 to do its work at idle times.

I'd sat we hook into the shell and call IdleNotification when we print the prompt and maybe when we return a scope back to the pool in general.

Comment by Eliot Horowitz (Inactive) [ 10/Nov/13 ]

This is an implementation detail of v8, and not something we will adjust.
gc() is meant to be background, not enforced.

Generated at Thu Feb 08 03:26:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.