On Thu, Sep 11, 2008 at 9:22 PM, Timothy Wall <twal...@dev.java.net> wrote:
If you're using very large structures and using them often, here's a tip
that can boost performance by several orders of magnitude. Note that you
should follow this tip *only* if you really need the performance boost;
otherwise you may wind up obfuscating your code.
By default, when JNA makes a native call it will copy the full contents of a
Java Structure to native memory prior to the call and read it all back after
the call. If your Structure is very large, this can result in significant
overhead reflecting all the fields of the Structure. The reflection dwarfs
the actual native communication time.
this seems to apply to my situation. before using JNA, I was using my
customized version of shared stubs, where struct was not really being
marshalled-unmarshalled on each call.
maybe there should be some kind of a "lazy" Structure. that would
require some re-factoring though. i'd require java beans style get/set
naming convention for structure fields (instead of public fields),
then inside those getters implement the lazy accessors.