[erlang-questions] Transferring list from java through JInterface

Martin Dimitrov <>
Sat Nov 26 22:51:55 CET 2011


Thanks for the info. I will definitely check it out.

I wonder, though, what is the difference between OtpErlangList and
OtpErlangBinary? I construct each one by passing List<String> to the
constructor. One is very slow, the other is very fast.


On 11/26/2011 10:27 PM, Florian Schintke wrote:
> Sounds related to the issue Niko Kruber found last week. He send a
> patch to erlang-patches for this already:
>
> You can fetch the patch from github:
>
> git fetch git://github.com/NicoK/otp.git jinterface_better_buffer_alloc
>
> https://github.com/NicoK/otp/compare/jinterface_better_buffer_alloc
> https://github.com/NicoK/otp/compare/jinterface_better_buffer_alloc.patch
>
> The problem is, that when the necessary buffer size is not known in
> advance, the buffer is constantly increased by only 2k, which leads to
> many in-memory copying. The patch changes that to increase the buffer
> by 50% in each step.
>
> Hope the patch will be accepted.
>
> Florian
>
> [Martin Dimitrov]
>> Hello,
>>
>> I have a huge list, about 500K strings each containing 3 chars. I
>> noticed it is very slow to construct an OtpErlangList out of the Java
>> List<String> and to send it to the Erlang process. When constructing an
>> OptErlangBinary out of the Java List<String>, it takes no time to
>> transfer. The problem is that the list gets concatenated. Is there a way
>> to avoid it?
>>
>> I also noticed that transferring a huge string (2.5MB) as
>> OtpErlangString is very slow while transferring it as OptErlangBinary is
>> very fast. Can you explain to me why is it so? Maybe I don't (fully)
>> understand the binary type.
>>
>> Thank you,
>>
>> Martin
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
> Florian




More information about the erlang-questions mailing list