My program is fast enough, but I would prefer to abandon this speed to optimize memory, because the maximum memory usage for a user is up to 300 MB means that some of them can constantly cause the application to crash. Most of the answers that I found were related to speed optimization, while others were just general ("if you write directly from the database to memory, there should not be much memory usage"). Well, it seems that there is :) I was thinking about not sending the code, so I would not βblockβ some ideas, but, on the other hand, I could waste your time if you do not see that I have already done so here it is:
EDIT: Here is an example of memory usage (using visualVM):

EDIT2: The database is Oracle 10.2.0.4. and I set ResultSet.TYPE_FORWARD_ONLY and got a maximum of 50 MB of use! As I said in the comments, I will follow up on this, but it is really promising.

EDIT3: There seems to be another possible optimization. As I said, I generate XML, which means that a lot of data is repeated (if nothing else, then tags), i.e. String.intern () can help me here, I will send a message when I do this.
source share