jna
  1. jna
  2. JNA-148

read() is slow on nested Structures -> recursion should be optional

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: not determined
    • Component/s: library
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      148

      Description

      When Structure.read() is called on nested Structures with large sub-structures
      it takes a very long time, even if one only needs to fill the first level of
      fields (i.e. if one is not interested in the (sub-)fields of the structure
      fields). Therefore it would be an important enhancement to provide a
      non-recursive version of read() (e.g. read(boolean recursive)) where the
      developer can decide wether the read process has to be called recursively for
      each ByReference structure field.
      Currently the only workaround for this is to work with pointer arithmetics using
      the right offsets of particular fields of the structure. This is not a trivial
      issue because the offsets cannot be determined during runtime (as the
      StructureField map is package private and cannot be accessed from application
      code), those one has to calculate the offsets manually (e.g. from the native C
      code). A solution for this would be appreciated very much!

        Activity

        Hide
        twalljava added a comment -

        The recursive call can also have adverse memory allocation effects, sometimes
        resulting in OOM conditions.

        Show
        twalljava added a comment - The recursive call can also have adverse memory allocation effects, sometimes resulting in OOM conditions.
        Hide
        rvandenh added a comment -

        Created an attachment (id=84)
        Suggested patch (Java part) for issue 148

        Show
        rvandenh added a comment - Created an attachment (id=84) Suggested patch (Java part) for issue 148
        Hide
        rvandenh added a comment -

        I suggested a patch (see above) that should solve issue 148 (at least on the
        Java part). I could not test the patch because it seems that also the native
        method Pointer._getPointer() has to be adapted accordingly.
        Note that my patch does NOT affect the current behaviour of JNA, it just adds
        new functionality (the option to call read() non-recursively). So the new API
        should be completely backwards-compatible.

        Show
        rvandenh added a comment - I suggested a patch (see above) that should solve issue 148 (at least on the Java part). I could not test the patch because it seems that also the native method Pointer._getPointer() has to be adapted accordingly. Note that my patch does NOT affect the current behaviour of JNA, it just adds new functionality (the option to call read() non-recursively). So the new API should be completely backwards-compatible.

          People

          • Assignee:
            jna-issues
            Reporter:
            rvandenh
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: