dragon-zhang commented on PR #10021:
URL: https://github.com/apache/dubbo/pull/10021#issuecomment-1147354748

   CN
         
请试着用逆向思维来思考,`MemorySafeLinkedBlockingQueue`做限制的判断是基于`JVM可用内存`的,比如JVM一共有1GB的内存,`MSLBQ`使用默认构造方法。`MSLBQ`会`随心所欲地使用内存`,但是会`尽可能地保证JVM剩余的内存>=256MB`;当发现JVM剩余内存<256MB时,`MSLBQ`会`拒绝写入`。
         
基于剩余内存判断的好处是,一方面能够`自适应不同的硬件`(1GB有756MB可用,2GB有1780MB),另一方面是能够以`较低成本`兼容大多数情况(不关心到底发生了多少次GC,不关心到底是YoungGC还是FullGC,因为这些最终都会导致`JVM可用内存`增加)。
   
   EN
       Please try to think in a reverse way. The judgment of 
`MemorySafeLinkedBlockingQueue` is based on `JVM available memory`. For 
example, the JVM has a total of 1GB of memory. `MSLBQ` uses the default 
construction method. `MSLBQ` will `use memory at will`, but will `try to ensure 
that the remaining memory in the JVM is >=256MB`; When the JVM's remaining 
memory is found to be <256MB, `MSLBQ` will `reject writing`.
       The advantage of judging based on the remaining memory is that, on the 
one hand, it can `adapt to different hardware`(756MB available for 1GB and 
1780mb available for 2GB), and on the other hand, it can be compatible with 
most cases at a `lower cost` (it doesn't care how many GCs occur, or whether it 
is YoungGC or FullGC, because these will eventually lead to an increase in `JVM 
available memory`).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to