Ngoc Dao
Ngoc Dao

Reputation: 1510

In Netty 4, do I need to set option -XX:MaxDirectMemorySize?

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

Upvotes: 1

Views: 6182

Answers (3)

Yoav Slomka
Yoav Slomka

Reputation: 372

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.

Upvotes: 1

trustin
trustin

Reputation: 12351

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.

Upvotes: 3

Norman Maurer
Norman Maurer

Reputation: 23567

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

Upvotes: 1

Related Questions