-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plug-ins leaking CodeLens, etc. #4472
Comments
For completions, there is a "dispose" method being called when the completion widget is closed, so we are able to clean up the cache when that happens. A cursory inspection has not yielded similar a similar lifecycle event for code lenses. Detecting that a code lens is no longer needed might be a difficult problem. |
There problem here is tracking when the code lenses are not used anymore in the main Theia process. In the absence of lifecycle events, maybe we can detect liveness by putting them in a WeakMap and regularly checking whether they are collected? Since we are talking about only few objects, we could do so relatively seldom (every 10 secs?) |
@tsmaeder @akosyakov [1] https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/services/heap/node/heap.ts#L11 |
|
@tolusha yes, that's why I suggested doing a weak map and purge thingy. The idea would be to have a map object->id and a set and when stuff gets collected from the map, the ids will be in the set, but not the map anymore and you can send "collected" to the back end. |
@tsmaeder |
@akosyakov @tsmaeder
|
@tolusha that would work for code lenses, but what about links & tasks? |
True about WeakMap. How lame! |
It's probably too late, if new code lenses are created on each text change.
Do you mean to keep I wonder can't we just remove them after resolving? Does Monaco try to resolve resolved code lenses again? Could you check? Also see microsoft/vscode#75048. Seems soon (like in Autumn) there will be |
@akosyakov Yeah, the idea was to put them in a weak map and check periodically if they have been collected. Problem is that you can't enumerate a WeakMap, so I don't see how we can implement that algorithm. If we could get the "live" code actions from monaco, we could also compute the "collected" set periodically.
What about the code lenses that are never resolved? Good to see that the MS folks are addressing the issue. The question is: can we live with the leakage until then? We should do an estimation of the garbage produced per hour. |
We could keep set of keys identifying code lenses and check periodically whether WeakMap still contains such keys? If not delete a key and release a corresponding code lens in the plugin host. |
That was my idea, too, but the problem is that the keys are what is weakly referenced in the WeakMap. So in this case, the CodeLens objects. If something is not in the map, how do we know it was there before? We would have to keep a strong reference to it, which would keep it from being garbage collected. |
Ah, sorry, i did not read Maybe we can play with |
Yes, I think that would work. At most, we would have one set of code lenses that are garbage, but not collected per open editor. |
The same workaround would work for linkProvider |
I think our implementation of the "taskProvider" API is wrong: https://code.visualstudio.com/api/references/vscode-api#TaskProvider says:
This would indicate that we should never call "resolveTask" on a task that is in the object cache in TaskProviderAdapter. So we can just remove the cache there and we're fine for this case. |
I believe with the above cases covered, we can proceed with this task. |
Monaco PR was merged. It should be possible to invalidate caches properly. |
@akosyakov, @tsmaeder It looks like Is it OK to clean up the cache every time |
How can I get such links?
I want to confirm first that we don't overlook it. VS Code relies on it, dispose method is there, maybe we overlook something or don't understand lifecycle of links. |
For some reason, they expect |
I'm running my branch (rebased over Theia master) as a Browser Example - and I have defined that
|
Links for markdown is not contributed by the plugin system. You should make sure that links are coming from the plugin host process, only then dispose should be called. |
Well then I should find another way yo get links, But then, should we do anything to clear the cache from the links like those for markdown? It looks like they are really never get removed from the cache. |
I've filed an issue for VS Code to check it. It looks like indeed links are leaking, but it should be fixed in the upstream first. We could try to hack around for the plugin host process, but all other links will leak anyway. |
It was fixed in the upstream today: microsoft/vscode#91536 (comment) I think it is going to be part of Monaco Feb release. It is important for us not only for the plugin system but fro built-in providers as well. |
@akosyakov Thanks! |
Fixes: eclipse-theia#4472 Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
Fixes: eclipse-theia#4472 Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
Fixes: #4472 Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
Fixes: #4472 Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
Fixes: eclipse-theia#4472 Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
In packages/plugin-ext/src/plugin/languages/lens.ts, we maintain a cache of CodeLens objects we send to the main Theia process. This is required because the VS Code languageserver-node client library relies on the same object being passed to the "resolveCodeLens" call in order to pass back the "data" field to a language server.
However, this cache is never cleaned up, so we're keeping all CodeLens objects that are ever created.
The same problem seems to exist in task-provider.ts and link-provider.ts.
The text was updated successfully, but these errors were encountered: