GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ObjectCleanerThread not be closed · Issue #7617 · netty/netty

ObjectCleanerThread not be closed #7617

New issue
Copy link
New issue
Copy link
Closed
Closed
ObjectCleanerThread not be closed#7617
Copy link
Assignees
normanmaurer
Labels
defect
Milestone
4.0.56.Final

Description

@hank-whu
hank-whu
opened on Jan 24, 2018
Issue body actions

Netty version

4.1.20.Final

JVM version (e.g. java -version)

9.0.1

OS version (e.g. uname -a)

Windows 10

Non-finished threads:

Thread[DestroyJavaVM,5,main]

Thread[ObjectCleanerThread,1,main]
at [email protected]/java.lang.Object.wait(Native Method)
at [email protected]/java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
at app//io.netty.util.internal.ObjectCleaner$1.run(ObjectCleaner.java:52)
at app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at [email protected]/java.lang.Thread.run(Thread.java:844)

Activity

Next
  1. normanmaurer commented on Jan 24, 2018

    @normanmaurer
    normanmaurer
    on Jan 24, 2018
    Member
    More actions

    @hank-whu it should be after 10 seconds maximum if there are no more references: https://github.com/netty/netty/blob/4.1/common/src/main/java/io/netty/util/internal/ObjectCleaner.java#L52

    Are you sure there are no more references hold ?

  2. johnou commented on Jan 24, 2018

    @johnou
    johnou
    on Jan 24, 2018
    Contributor
    More actions

    @normanmaurer why isn't there a break in the loop if the thread is interrupted? wouldn't that indicate the application is shutting down?

  3. normanmaurer commented on Jan 24, 2018

    @normanmaurer
    normanmaurer
    on Jan 24, 2018
    Member
    More actions

    @johnou I think it should still cary on cleanup until there are no more references as otherwise we may leak direct memory etc. It should only exit once the LIVE_SET is empty imho.

  4. johnou commented on Jan 24, 2018

    @johnou
    johnou
    on Jan 24, 2018
    Contributor
    More actions

    @normanmaurer then how about a daemon thread? Allowing the JVM process to terminate in a timely manner.

  5. normanmaurer commented on Jan 24, 2018

    @normanmaurer
    normanmaurer
    on Jan 24, 2018
    Member
    More actions

    @johnou we decided against a daemon thread to make harder guarantees about cleanup. If it would be a deamon thread we may leak direct memory for example when someone hot-deploy stuff.

    Also /cc @Scottmitch , as both of us had the discussion :)

  6. Scottmitch commented on Jan 25, 2018

    @Scottmitch
    Scottmitch
    on Jan 25, 2018
    Member
    More actions

    Yes we considered daemon but decided against it. Although I would expect most OSes we run on will clean up process resources after the process dies we can’t be sure of this. Since we allocate native resources outside the scope of the JVM the more conservative approach is to go non daemon. The mitigation factor was to have a timeout on the poll. This may cause issues if some of the jvm shutdown processing contains references to items registered in the cleaner but this seemed unlikely when the discussion took place.

  7. hank-whu commented on Jan 25, 2018

    @hank-whu
    hank-whu
    on Jan 25, 2018
    Author
    More actions

    @normanmaurer
    shoud i wait 10 seconds after shutdown the EventLoopGroup ?
    it doesn't seem like a good way.
    can add a "shutdown(long mills)" method to ObjectCleanerThread ?

  8. normanmaurer commented on Jan 25, 2018

    @normanmaurer
    normanmaurer
    on Jan 25, 2018
    Member
    More actions

    @hank-whu it may take up to 10 seconds... That said you can tune this with a system property:

    https://github.com/netty/netty/blob/4.1/common/src/main/java/io/netty/util/internal/ObjectCleaner.java#L36

  9. johnou commented on Jan 25, 2018

    @johnou
    johnou
    on Jan 25, 2018
    Contributor
    More actions

    @normanmaurer it can actually stop the jvm from terminating, I'll post more details shortly.

  10. normanmaurer commented on Jan 25, 2018

    @normanmaurer
    normanmaurer
    on Jan 25, 2018 via email
    Member
    More actions
    Thx...
    …
    Am 25.01.2018 um 09:27 schrieb Johno Crawford ***@***.***>: @normanmaurer it can actually stop the jvm from terminating, I'll post more details shortly. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
  11. hank-whu commented on Jan 25, 2018

    @hank-whu
    hank-whu
    on Jan 25, 2018
    Author
    More actions

    Ensure all threads are closed, "wait some time" is the only way.
    I think this is not very good.
    I need a method to ensure all threads are closed.

  12. johnou commented on Jan 25, 2018

    @johnou
    johnou
    on Jan 25, 2018
    Contributor
    More actions

    @normanmaurer I would expect something like this to exit gracefully without an explicit System.exit call.

    public class Main {
    
        public static void main(String[] args) {
            ByteBuf byteBuf = PooledByteBufAllocator.DEFAULT.buffer();
            byteBuf.release();
            System.gc();
            System.runFinalization();
            // hangs because ObjectCleanerThread is not a daemon thread / LIVE_SET is not empty..
        }
    }
    Reacted by Jay Modi and Laraka | Lara Bärtschi
  13. normanmaurer commented on Jan 25, 2018

    @normanmaurer
    normanmaurer
    on Jan 25, 2018
    Member
    More actions

    @johnou @hank-whu after reading more up on all of this I think you are right and @Scottmitch and myself were wrong .... This must be a deamon thread to ensure we will be able to shutdown in all cases. OpenJDK itself also uses a deamon thread and the GC threads are also deamon threads:
    https://github.com/dmlloyd/openjdk/blob/342a565a2da8abd69c4ab85e285bb5f03b48b2c9/src/java.base/share/classes/jdk/internal/ref/CleanerImpl.java#L117

    Let me come up with a PR

    Reacted by Johno Crawford
  14. normanmaurer commented on Jan 25, 2018

    @normanmaurer
    normanmaurer
    on Jan 25, 2018
    Member
    More actions

    @hank-whu @johnou #7627 PTAL

  15. 13 remaining items

  16. slandelle commented on Jan 31, 2018

    @slandelle
    slandelle
    on Jan 31, 2018
    Contributor
    More actions

    Wow, great, you rock!

  17. ivankelly
    added a commit that references this issue on Jan 31, 2018

    Debump netty version by 1 due to ObjectCleaner bug

    eaa58db
  18. merlimat
    added a commit that references this issue on Feb 1, 2018

    Debump netty version by 1 due to ObjectCleaner bug (#1163)

    f2073d1
  19. mfussenegger
    added 2 commits that reference this issue on Feb 1, 2018

    Update netty to 4.1.19

    2787d9e

    Update netty to 4.1.19

    bb409a2
  20. ldaley
    added a commit that references this issue on Feb 5, 2018

    Roll back to Netty 4.1.19 due to netty/netty#7617

    82a6810
  21. mfussenegger
    added 2 commits that reference this issue on Feb 5, 2018

    Update netty to 4.1.19

    f2e473a

    Update netty to 4.1.19

    7dcde1b
  22. johnou
    added 2 commits that reference this issue on Feb 7, 2018

    async-http-client 2.3.0

    9fef270

    async-http-client 2.3.0 (#238)

    9357137
  23. kiril-me
    added a commit that references this issue on Feb 28, 2018

    ObjectCleanerThread must be a deamon thread to ensure the JVM can alw…

    f2f2a34
  24. mcfongtw commented on May 7, 2018

    @mcfongtw
    mcfongtw
    on May 7, 2018
    More actions

    Hi, is this fix included in any 4.1.x release yet?

  25. fenik17 commented on May 7, 2018

    @fenik17
    fenik17
    on May 7, 2018
    Contributor
    More actions

    @mcfongtw yep. since 4.1.21.

  26. mcfongtw commented on May 7, 2018

    @mcfongtw
    mcfongtw
    on May 7, 2018
    More actions

    Thanks. @fenik17

  27. pulllock
    added a commit that references this issue on Oct 19, 2023

    ObjectCleanerThread must be a deamon thread to ensure the JVM can alw…

    849126b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @normanmaurer
    normanmaurer

Labels

defect

Type

No type

Projects

No projects

    Milestone

    • 4.0.56.Final

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.