Nagappa L M
Nagappa L M

Reputation: 1480

Why is Struts 2.x made as a multiton? What are the advantages over Struts 1.x?

My team decided to use Struts 2.x but I am confused because Struts 1.x actions are singletons, multi-threaded on the action like servlets. Struts 2.x creates new instances on every request, which increases heap memory usage.

Does using Struts 2.x require more memory?

Upvotes: 0

Views: 161

Answers (1)

Dave Newton
Dave Newton

Reputation: 160181

Object instantiation in Java is very cheap, so there's no performance problem.

The garbage collector takes care of efficiently reclaiming memory of any objects created during the call, so there's no significant memory impact.

The advantages however are obvious: there's no shared state between requests.

Upvotes: 5

Related Questions