Skip to content
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

能否手动释放.node文件的占用? #3

Open
gitsheny opened this issue Nov 13, 2024 · 2 comments
Open

能否手动释放.node文件的占用? #3

gitsheny opened this issue Nov 13, 2024 · 2 comments

Comments

@gitsheny
Copy link

我在 electron 中有个函数动态引入这个库,函数结束后,在不退出 electron 的情况下, regedit-rs.win32-x64-msvc.node 文件仍然被占用。有办法手动释放吗?

async function test(){
  let regedit = require('regedit-rs')
  await regedit.createKey(`HKCU\\Software\\1-test`)
  regedit = null
}
@Zagrios
Copy link
Owner

Zagrios commented Nov 13, 2024

@gitsheny That's not something the library itself can act on, but you can try this:

async function test() {
  let regedit = require('regedit-rs');
  await regedit.createKey(`HKCU\\Software\\1-test`);
  
  // Remove from cache
  delete require.cache[require.resolve('regedit-rs')];
  
  // Optionally nullify the reference
  regedit = null;
}

@gitsheny
Copy link
Author

@gitsheny That's not something the library itself can act on, but you can try this:

async function test() {
  let regedit = require('regedit-rs');
  await regedit.createKey(`HKCU\\Software\\1-test`);
  
  // Remove from cache
  delete require.cache[require.resolve('regedit-rs')];
  
  // Optionally nullify the reference
  regedit = null;
}

上面的方法我试了没有效果。但是我用worker线程可以成功释放,只是我每次写worker有些繁琐。你能否集成一个worker线程版本的吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants