You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Bryan Duxbury (JIRA)" <ji...@apache.org> on 2009/10/01 20:20:23 UTC

[jira] Commented: (THRIFT-594) Add "intern" method to generated structs

    [ https://issues.apache.org/jira/browse/THRIFT-594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761291#action_12761291 ] 

Bryan Duxbury commented on THRIFT-594:
--------------------------------------

@David: using a separate object as the intern table makes things a little complicated, because then you need to pass that object around. I think the best thing to do would be to use a WeakReference-based map for the intern table so that as soon as nothing references it, the object can be garbage collected.

@Esteve: I think an allocator scheme would be more complicated than just having an intern method. If we wanted to have allocators that could have this behavior, I would think they'd just call the intern method, anyway.

> Add "intern" method to generated structs
> ----------------------------------------
>
>                 Key: THRIFT-594
>                 URL: https://issues.apache.org/jira/browse/THRIFT-594
>             Project: Thrift
>          Issue Type: New Feature
>          Components: Compiler (Java), Library (Java)
>    Affects Versions: 0.2
>            Reporter: Bryan Duxbury
>            Priority: Minor
>             Fix For: 0.2
>
>
> Thrift structs can take up a lot of memory in Java. In my particular application, many of the structs I load have common subcomponents. When deserializing these structs today, each copy of the common subcomponents takes up a fresh chunk of memory. 
> To reduce this memory usage, I propose that we add an "intern" method to Thrift structs. This method would maintain a static class-level cache of canonical versions of instances of objects. When calling "intern", if the object was not in the cache, it would add it and return the same struct. If it was in the cache, it would return the canonical version, allowing the non-canonical version to be dropped during garbage collection.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.