#When data will be removed from memory in the loop

1 messages · Page 1 of 1 (latest)

worthy breach
#

So if I have loop like this

while (scanner.hasNextLine()) {
       String line = scanner.nextLine();
       String[] parts = line.split(",");
       if (parts.length >= 9) {
           String equipmentDescr = parts[0];

        ...
}

will at X + 1 iteration data that was stored in X iteration be erased, like it will not be in the memory? For example what was stored in line or equipmentDescr at X iteration, will it be still at memory at X + 1 iteration?

So I am doing work of getting data from CSV file and saving it to database, I first did saved data from CSV file into objects at for that I needed 700mb. I thought that if I do not save data into objects but insert data into database as I loop I will save up on memory, but I did not, so I guess for instance what was stored in X iteration at line or parts will not be completely erased at memory at X + 1 or X + 2 iteration

upper oakBOT
#

<@&987246399047479336> please have a look, thanks.

upper oakBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

rich bluff
worthy breach
worthy breach
rich bluff
#

But I doubt this will matter for you

worthy breach
#

Why you doubt that?

rich bluff
#

Since what are you doing of those variables ?

worthy breach
#

I am passing them to method from which I call another custom query method for inserting data to database

rich bluff
#

Show the whole code please

worthy breach
#

It is not like I am adding that data into constructor and using created objects for some time, I just pass data to method which calls custom JpaRepository query for insertion

rich bluff
worthy breach
#

Not almost immediately when particular iteration from which data was created is over