weixin_39687881 2020-11-21 21:17 采纳率: 0%
浏览 0

Garbage collection of Python objects with ClientServer

  1. If Java drives the conversation, the server should always be started to avoid a situation where a Python thread garbage collect an object and tries to communicate with the JVM (without a server, only the Python thread receiving a command from the Java side can respond).
  2. I need to dive into Python source code, but what if the garbage collector runs on the Python thread after sending back the response to the Java side (just before waiting for the Java side command)? It would try to send more information and would never receive a response...?
  3. Would it be desirable to run gc.collect() before sending back the response? This could be an option (enabled by default)? I tested that the thread that runs gc.collect() is the one executing the finalizers.
  4. This should not be an issue with traditional threading model because threads are created on demand (although if the current thread can be interrupted, this may be problematic).

该提问来源于开源项目:bartdag/py4j

  • 写回答

5条回答 默认 最新

  • weixin_39687881 2020-11-21 21:17
    关注

    It seems gc collection occurs only when an object is referenced, dereferenced, or created.

    Nobody ever reported a problem with gc with the traditional threading model, but I will need to perform some stress test to see how the interpreter behaves when creating many objects.

    评论

报告相同问题?