question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Callback is still getting garbage collected.

See original GitHub issue

Our macOS electron app uses nodobjc with ffi, and we have been getting “ffi: callback has been garbage collected” errors. To detect the error, I added test code to our app that will loop forever making async calls from javascript, one at a time, waiting for completion each time. Somewhere between 0 and 200 iterations, we get the error, usually at 50 to 100, but it does seem randomish.

Last week I created a local “nodobjc-napi” on my machine, that uses ffi-napi 2.4.0, which has the workaround of Callback is garbage collected.

My test code still sees the same error with the same frequency. I searched my node_modules and app/node_modules for the original ffi, but all I see is ffi-napi, so as far as I can tell the workaround is active.

We use nodobjc for our authentication flow, and if it doesn’t work, then about 2% of our customers (randomishly distributed) won’t be able to sign in at any given time.

Is there some way I can help to diagnose this, or to be a test bed if anyone wants to experiment? I can try adding delays, additional logging, other code, I can stay up late and spend some time on weekends. What I can’t do is actually solve the problem, because I lack the skill set. Help!

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
atishaycommented, Jan 29, 2020
0reactions
addaleaxcommented, Jan 31, 2018

@stuartbrussell-intuit It is a weak reference because it cannot know how long C is going to need access to it; so the alternative would be storing it forever, which would always lead to a memory leak.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Garbage Collection and Callbacks - java - Stack Overflow
If you get an object of array, list, or whatever, then it's easy to deference it when you can and as soon as...
Read more >
callback made on a garbage collected delegate - MSDN
callbacks. cbPriceLinkStateChange is called by a background thread and throws the exception before it enters the method - as it has been garbage...
Read more >
Causes of Memory Leaks in JavaScript and How to Avoid Them
1. Accidental global variables # ... Global variables are always available from the root and will never get garbage collected. Some mistakes cause...
Read more >
Using method in SET-CALLBACK() triggers unexpected ...
Using method in SET-CALLBACK() can result in objects being garbage-collected unexpectedly. This also affects static portions of a class, which ...
Read more >
gc — Garbage Collector interface — Python 3.11.1 ...
A list of callbacks that will be invoked by the garbage collector before and after collection. The callbacks will be called with two...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found