0

In Java, we create an object from a class, And the class is in the heap memory,

How can this class be cleared of this memory after the completion of the task?

Looking for a command or code, or whatever, to control the memory occupied by Java and empty it if necessary.

Thank.

Bardia Namjoo
  • 11
  • 1
  • 4
  • 1
    Are you asking about the memory occupied by the object, or the memory occupied by the class? – Dawood ibn Kareem Apr 15 '18 at 08:57
  • yes,I want to empty this memory after work – Bardia Namjoo Apr 15 '18 at 09:36
  • Yes, do you want to empty the memory occupied by the object? Or do you want to empty the memory occupied by the class? Or do you not understand the difference? Your question is very unclear. – Dawood ibn Kareem Apr 15 '18 at 09:44
  • I also want to remove that class from memory after class completion, and I also want to empty memory if necessary. – Bardia Namjoo Apr 15 '18 at 09:52
  • I would like to use both of them if necessary – Bardia Namjoo Apr 15 '18 at 09:53
  • What do you mean by "after class completion"? Anyway, if you really want to expel loaded classes from memory, you'd have to write your own ClassLoader implementation. This is a huge subject, and a bit too broad to be answered on Stack Overflow. – Dawood ibn Kareem Apr 15 '18 at 10:09
  • Thank you very much for your answer. I mean, we use the class and we no longer need it. In relation to ClassLoader, please explain a bit to search on Google to learn this. – Bardia Namjoo Apr 15 '18 at 10:48

0 Answers0