Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-594

Add "intern" method to generated structs

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 0.2
    • None
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              bryanduxbury Bryan Duxbury
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: