I cannot find the ObjectSizeEstimator class in Netty 4. Was this class in version 3, which allowed me to monitor how much memory netty was using, was it removed in Netty 4? If it was removed, is there a replacement for this class in Netty 4?

  • As far as I can see from the documentation, he simply returned the amount of heap to be occupied by the object. I do not know why it may be needed in Netty, but you can write your own version like this . - Sergey Gornostaev
  • Sergey Gornostaev, this is not only the case; he not only returned the volume of the heap, but also stopped the threads if the volume exceeded the value specified by the programmer in the constructor of the class "OrderedMemoryAwareThreadPoolExecutor" and resumed work when the memory was released. At least it was in version 3, maybe I'm wrong - cvxbcvbsd fsddfgdfg
  • It did not stop, it was only used for measurements by the OrderedMemoryAwareThreadPoolExecutor itself. Which is also no longer in Netty 4. If you need this functionality, you will have to inherit from any EventExecutorGroup implementation and override the submit method. Why do you need this? - Sergey Gornostaev
  • Sergey Gornostaev, Yes, I'm sorry I was wrong. I need this to avoid outofmemoryerror type exceptions, etc., In case Netty starts to consume too much memory on the server. I think it is necessary to somehow control, suspend work, clean the garbage collector. Otherwise everything will fly, I will honestly say that I am not a professional, maybe I’m wrong about something. - cvxbcvbsd fsddfgdfg
  • Firstly, when using Netty, it is better to reduce heap usage to the maximum, to operate with byte buffers in native memory. Secondly, you can catch OOM only in two cases - with leaks and when the cumulative memory usage of all connections is greater than what the server has. The first is solved by carefully writing the code, the second is not solved in principle, except by the refusal to accept new connections. - Sergey Gornostaev

0