0 Replies Latest reply: Oct 8, 2009 4:59 AM by 843829 RSS

    Stack only objects

    843829
      Hello,

      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;
      }