I am trying to optimize memory usage. After reading this article on memory manage http://www.tidev.io/2014/03/27/memory-management/, I want to store user object in commonjs module not in Alloy.Globals(current implementation). As user object is required in almost every screens, so I need include that commonjs module in every controllers, will it not increase memory usage? I know, titanium caches commonjs modules. But I am really not clear how it is going reduce memory usage. Can anyone please explain me how exactly commonjs module works when it is loaded first time and then loaded in subsequent screens.
Putting something on the global namespace, or putting them in a lib will not reduce your overall memory usage. Especially if you are going to require it everywhere there is no point. The benefit of a lib is when you only require it sometimes it is only loaded when actually needed.
So in your case there is no need to refactor it purely for memory reasons.
However it is recommended to put functionality in lib folders for organisation purposes.