Thanks a lot!
Finally, I realized that I have a memory problem if I try to write 13 or18 Millions of similarityPairs (and it's not useful). However adding the parameter topK I reduced the number and it writes without problem.
In your example you actually write 2864 similarityPairs (using topK:5), not the total ~ 292Millions. I'm sorry for the misunderstanding