Miscellaneous
Managing Desktop Memory References
Our @todesktop/client-core
NPM package enables access to native desktop features from your client-side application. This enables powerful functionality, such as allowing you to create windows with just a few lines of code:
To make this work, we retain a record of the references (e.g. windowRef
) that are used between the desktop and the web process. We also provide functionality through the function object.releaseMemoryBindings
to delete these references when they're no longer needed. This is important for managing the desktop app's memory footprint.
Following our previous example, we can destroy the created window and release it's associated memory reference with the following:
While this works as expected, it's usually better to reactively release references in response to some termination event. This helps us catch cases where the window is closed outside of our direct control: