K
K
krembrule20162019-07-23 21:37:49
Java
krembrule2016, 2019-07-23 21:37:49

Should collections be deleted? And how to do it right?

Hello!
In short, I fell ill here and, under a high temperature, the thought came to my mind that it was necessary to think about the topic - but am I, in fact, programming correctly. Well, after recovering, I took a look at my recent project and the following question popped up in my mind:
Let's say there is a certain function that works when a user pokes his wretched Chinese huyawei on the screen. This function is written something like:

ArrayList<Float> yaOsvoilColleKcii = new ArrayList<Float>();

Further means something there the collection is filled, but it is unimportant. But! In this case, the user can tap on the screen several times in succession. As a result, these collections will multiply in our memory and will not disappear anywhere? Those. Will the RAM of the Huawei be clogged until it bursts? Those. whether it is necessary to delete this collection from memory after working off of function somehow? And if you poked at the same time several times, then what will happen? Will two or more collections appear in memory at once, but with the same name? I honestly googled, but everywhere there are only instructions ala how to use collections. I ask more experienced to clarify this issue.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Gornostaev, 2019-07-24
@krembrule2016

Reduce the scope of variables, and then the JVM itself will take care of everything.

I
illuzor, 2019-07-23
@iLLuzor

Is this some kind of trolling?
If not, read about the jvm memory model and the work of the garbage collector

V
Viktor Taran, 2017-11-07
@shambler81

RewriteCond %{QUERY_STRING} (^|&)id\=1($|&)
RewriteCond %{QUERY_STRING} (^|&)page\=2($|&)
RewriteRule .* odemix.ru/note1\?page2? [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question