1

Netty 4 can use direct memory. I think I should/must set option -XX:MaxDirectMemorySize when starting Java process that uses Netty.

3 Answers 3

3

It really depends on how much direct memory your application is going to use. By default, the maximum available size of direct memory of JVM is same with the maximum heap size, although it differs between JVM vendors and versions.

io.netty.util.internal.PlatformDependent.maxDirectMemory() returns the maximum direct memory size in bytes, so you might want to use it for debugging purposes. Actually, Netty logs that value if you set the log level of io.netty.util.internal.PlatformDependent to DEBUG.

1

You don't need too.. But it will give the JVM a hint how much direct memory is allowed to be allocated.

2
  • If that option is not set, Netty can only use up to 64 MB of direct memory?
    – Ngoc Dao
    Jan 23, 2014 at 7:15
  • 1
    You can get the maximum available direct memory via PlatformDependent.maxDirectMemory()
    – trustin
    Jan 24, 2014 at 7:04
1

I think that in most cases you won't need to set the direct memory size. If you get to a point were you run out of direct memory, you should first see if you are using the direct memory correctly before setting it manually. Check that you are not creating to many io workers and by that Creating to many direct buffers instead reusing io workers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.