0

Many time i facing the "java.lang.OutOfMemoryError: Java heap space" error, is there any problem with new keyword, because i used new keyword many time for creating object of class in web application.

Mehul Dudhat
  • 421
  • 1
  • 7
  • 19
  • the size of the object – Marco Acierno Jul 02 '14 at 12:05
  • suppose i am using Users us = new Users(); in user class have many variable then calculate the all the variable size? – Mehul Dudhat Jul 02 '14 at 12:09
  • 2
    A Java object is as big as it is. It's pretty much impossible to define a class which will, by itself and without creating more objects in its constructor, cause an out of storage condition, but if you create enough objects (or even a single gigantic array) then you can run out of storage. If you keep getting OutOFMemoryError, you no doubt have some sort of bug in your code, but it's hard to guess what. – Hot Licks Jul 02 '14 at 12:12
  • (Learn how to examine the exception stack trace to understand what your code was doing when it blew up.) – Hot Licks Jul 02 '14 at 12:14

0 Answers0