I am getting a nice SystemOutOfMemory exception in my StringBuilders. It is not due to lack of ram, thus I believe it is memory fragmentation.
I have ~200 StringBuiler objects. All of these are reused regularly (with strBldr.clear()). This seems to cause my system to fragment the memory pretty bad. How can I solve this?
Thanks :)
EDIT:
Here are some data:
Max recorded size of input& stringBuilder: 4 146 698.
Avarage re-initiated stringBuilders/second: >120 (possibly >>120)
Length of input @ first error: 16 972 (string)
StringBuilder length @ first error: 16
Count of times a new stringBuilder had been made @ first error: ~32500
Total ram usage @ first error 637 448K
I agree, most likely you are not running out of memory but into fragmentation.
You have to get acquainted with fragmentation and the Large Object heap (LOH).
You don't provide any details so I can only give some very broad advice:
Edit
Max recorded size of input& stringBuilder: 4 146 698.
sb1 = new StringBuilder(4200000);