0 Replies Latest reply on Oct 8, 2009 9:59 AM by 843829

    Stack only objects


      I have a question regarding 'stack only' objects. If an object is created within a method
      body and never assigned to any variable outside of it, does it get deallocated when
      the method exits, or will it linger until the garbage collector makes its next sweep?

      For example, when exactly does "action" disappear from memory in this snippet:
      public int doSomething(String param) {
          TheAction action = new TheAction(param);
          int result = action.call();
          return result;