[ 
https://issues.apache.org/jira/browse/FLINK-26705?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

hd zhou closed FLINK-26705.
---------------------------
    Resolution: Abandoned

> use threadlocal to decrease ObjectSizeCalculator memory use
> -----------------------------------------------------------
>
>                 Key: FLINK-26705
>                 URL: https://issues.apache.org/jira/browse/FLINK-26705
>             Project: Flink
>          Issue Type: Improvement
>            Reporter: hd zhou
>            Priority: Major
>
> in class ObjectSizeCalculator
> everytime call static function getObjectSize will new ObjectSizeCalculator, 
> cost much memory, Gc busy. use threadlocal will decrease memory use
>  
> {code:java}
> /**
>  * Given an object, returns the total allocated size, in bytes, of the object 
> and all other objects reachable from it.
>  * Attempts to to detect the current JVM memory layout, but may fail with 
> {@link UnsupportedOperationException};
>  *
>  * @param obj the object; can be null. Passing in a {@link java.lang.Class} 
> object doesn't do anything special, it
>  *        measures the size of all objects reachable through it (which will 
> include its class loader, and by
>  *        extension, all other Class objects loaded by the same loader, and 
> all the parent class loaders). It doesn't
>  *        provide the size of the static fields in the JVM class that the 
> Class object represents.
>  * @return the total allocated size of the object and all other objects it 
> retains.
>  * @throws UnsupportedOperationException if the current vm memory layout 
> cannot be detected.
>  */
> public static long getObjectSize(Object obj) throws 
> UnsupportedOperationException {
>   return obj == null ? 0 : new 
> ObjectSizeCalculator(CurrentLayout.SPEC).calculateObjectSize(obj);
> } {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to