When the profiler starts up, it should give you a dialog with the option
to keep allocation traces. Then, in any memory snapshot, you should be
able to click on an instance and view the stack trace.

Also, setting breakpoints on the constructor of the Singleton should also
catch instantiation of it.

-Alex

On 11/13/14, 5:30 PM, "mark goldin" <markzolo...@gmail.com> wrote:

>How do I see these stack traces?
>
>On Thu, Nov 13, 2014 at 4:25 PM, Alex Harui <aha...@adobe.com> wrote:
>
>> Interesting.  What are the allocation stack traces of the instances?
>>
>> On 11/13/14, 1:49 PM, "mark goldin" <markzolo...@gmail.com> wrote:
>>
>> >Just tried Profiler and it does show multiple Instances of ModelLocator
>> >that are increasing every time I run the screen.
>> >
>> >On Thu, Nov 13, 2014 at 3:43 PM, mark goldin <markzolo...@gmail.com>
>> >wrote:
>> >
>> >> 1. singleton:
>> >> package
>> >> {
>> >> import com.adobe.cairngorm.model.IModelLocator;
>> >> import com.instepsoftware.prism.vo.AutoGenerated.ReportResult;
>> >>  import flash.events.EventDispatcher;
>> >>
>> >> [Bindable]
>> >> public class ModelLocator extends EventDispatcher implements
>> >>IModelLocator
>> >> {
>> >> private static var _instance:ModelLocator = new ModelLocator();
>> >> public var healthReport:ReportResult;
>> >>
>> >> public function ModelLocator()
>> >> {
>> >> }
>> >>  public static function getInstance():ModelLocator
>> >> {
>> >> return _instance;
>> >> }
>> >> }
>> >> }
>> >> 2. ReportResult:
>> >> package
>> >> {
>> >>
>> >> [Bindable]
>> >> [RemoteClass(alias=".............ReportResult")]
>> >> public class ReportResult
>> >> {
>> >> public var ReportXMLDoc:String = null;
>> >> }
>> >> }
>> >> Command to handle EventWhichWillPopulateData event:
>> >> private var _Model:ModelLocator = ModelLocator.getInstance();
>> >> public function result(data:Object):void
>> >> {
>> >> var re:ResultEvent = data as ResultEvent;
>> >> _Model.healthReport = re.result as ReportResult;
>> >> // data is here every time I run it
>> >> }
>> >> 3. Implementation:
>> >> mxml file:
>> >> creationComplete="creationCompleteHandler(event)"
>> >> ......
>> >> [Bindable]
>> >> private var _ModelLocator = ModelLocator.getInstance();
>> >> ....
>> >> protected function creationCompleteHandler(event:FlexEvent):void
>> >> {
>> >> dispatchEvent(new EventWhichWillPopulateData());
>> >> }
>> >>
>> >> <anothercomponenttoshowdata>
>> >>     dataProvider="{_ModelLocator.healthReport}"
>> >> </anothercomponenttoshowdata>
>> >> end of mxml file
>> >>
>> >>
>> >> 4. anothercomponenttoshowdata:
>> >> public function set dataProvider(value:ReportResult):void
>> >> {
>> >> if (value)
>> >> {
>> >> .......
>> >> }
>> >> }
>> >>
>> >> That is close to real code.
>> >> I know for sure that _ModelLocator.healthReport gets data in the
>>result
>> >> function. The whole thing works for the one time only.
>> >> Any consecutive run will have _ModelLocator.healthReport = null in
>>set
>> >> dataProvider.
>> >>
>> >> That's how the whole chain of questions was triggered because I
>>started
>> >> looking for workarounds.
>> >>
>> >> Sorry if that is still not clear.
>> >>
>> >>
>> >> On Thu, Nov 13, 2014 at 3:19 PM, mark goldin <markzolo...@gmail.com>
>> >> wrote:
>> >>
>> >>> I will try again. But this is a commercial application we are
>>talking
>> >>> about and it takes some effort to prepare simplified code.
>>Otherwise I
>> >>> would just dumb the whole damn thing.
>> >>>
>> >>> On Thu, Nov 13, 2014 at 3:17 PM, mark goldin <markzolo...@gmail.com>
>> >>> wrote:
>> >>>
>> >>>> Agree about details. But do not with overlapping.
>> >>>> Your label does not show its text. Can you imagine how many
>>problems
>> >>>> that can be caused by? But here we are talking about singletons and
>> >>>> binding, a bit more complicated, at least for me.
>> >>>>
>> >>>> On Thu, Nov 13, 2014 at 3:12 PM, OmPrakash Muppirala <
>> >>>> bigosma...@gmail.com> wrote:
>> >>>>
>> >>>>> On Thu, Nov 13, 2014 at 1:09 PM, mark goldin
>><markzolo...@gmail.com>
>> >>>>> wrote:
>> >>>>>
>> >>>>> > I am very sorry for the confusion. I do have it in exactly same
>> >>>>>way.
>> >>>>> I was
>> >>>>> > trying not to provide too much details. What can I say ...
>> >>>>> >
>> >>>>> >
>> >>>>> You should always try to provide as much detail as possible when
>> >>>>>asking
>> >>>>> a
>> >>>>> question.  Also, please try not to create multiple threads at the
>> >>>>>same
>> >>>>> time
>> >>>>> talking about overlapping issues.
>> >>>>>
>> >>>>> Thanks,
>> >>>>> Om
>> >>>>>
>> >>>>>
>> >>>>> > On Thu, Nov 13, 2014 at 3:04 PM, Alex Harui <aha...@adobe.com>
>> >>>>>wrote:
>> >>>>> >
>> >>>>> > > In this example, the ‘data’ property is an Object.  Properties
>> >>>>> assigned
>> >>>>> > to
>> >>>>> > > Objects are not bindable.  There should have been warnings in
>>the
>> >>>>> compile
>> >>>>> > > output or in the console at runtime.
>> >>>>> > >
>> >>>>> > > If you know the set of properties on the data object, you
>>should
>> >>>>> define a
>> >>>>> > > class for that.
>> >>>>> > >
>> >>>>> > > [Bindable]
>> >>>>> > > public class MyModelDataSubObject
>> >>>>> > > {
>> >>>>> > >    public var propOnData:String;
>> >>>>> > > }
>> >>>>> > >
>> >>>>> > > And:
>> >>>>> > >
>> >>>>> > > [Bindable]
>> >>>>> > > public class ModelLocator extends EventDispatcher implements
>> >>>>> > IModelLocator
>> >>>>> > > {
>> >>>>> > > private static var _instance:ModelLocator;
>> >>>>> > > public var data:MyModelDataSubObject;
>> >>>>> > > public function ModelLocator(enforcer:SingletonEnforcer)
>> >>>>> > > ..
>> >>>>> > >
>> >>>>> > >
>> >>>>> > > -Alex
>> >>>>> > >
>> >>>>> > > On 11/13/14, 12:49 PM, "mark goldin" <markzolo...@gmail.com>
>> >>>>>wrote:
>> >>>>> > >
>> >>>>> > > >Something like this. A bit simplified:
>> >>>>> > > >package
>> >>>>> > > >{
>> >>>>> > > >
>> >>>>> > > >[Bindable]
>> >>>>> > > >public class ModelLocator extends EventDispatcher implements
>> >>>>> > IModelLocator
>> >>>>> > > >{
>> >>>>> > > >private static var _instance:ModelLocator;
>> >>>>> > > >public var data:Object;
>> >>>>> > > > public function ModelLocator(enforcer:SingletonEnforcer)
>> >>>>> > > >{
>> >>>>> > > >if (enforcer == null){
>> >>>>> > > >throw new Error("You can have only one ModelLocator");
>> >>>>> > > >}
>> >>>>> > > >}
>> >>>>> > > > public static function getInstance():ModelLocator{
>> >>>>> > > > if (_instance == null){
>> >>>>> > > >_instance = new ModelLocator(new SingletonEnforcer());
>> >>>>> > > > }
>> >>>>> > > > return _instance;
>> >>>>> > > > }
>> >>>>> > > >}
>> >>>>> > > >}
>> >>>>> > > >class SingletonEnforcer{}
>> >>>>> > > >
>> >>>>> > > >
>> >>>>> > > >On Thu, Nov 13, 2014 at 2:44 PM, Alex Harui
>><aha...@adobe.com>
>> >>>>> wrote:
>> >>>>> > > >
>> >>>>> > > >> Declaring a class [Bindable] does not make its sub-objects
>> >>>>> bindable.
>> >>>>> > > >>Show
>> >>>>> > > >> us the code for the model’s data property.
>> >>>>> > > >>
>> >>>>> > > >> -Alex
>> >>>>> > > >>
>> >>>>> > > >> On 11/13/14, 12:31 PM, "mark goldin"
>><markzolo...@gmail.com>
>> >>>>> wrote:
>> >>>>> > > >>
>> >>>>> > > >> >It's an object. The whole model class is Bindable.
>> >>>>> > > >> >
>> >>>>> > > >> >On Thu, Nov 13, 2014 at 2:11 PM, Alex Harui
>> >>>>><aha...@adobe.com>
>> >>>>> > wrote:
>> >>>>> > > >> >
>> >>>>> > > >> >> It appears you are binding to sub-objects in the model,
>>and
>> >>>>> they
>> >>>>> > may
>> >>>>> > > >>not
>> >>>>> > > >> >> be bindable.  What is _model.data?
>> >>>>> > > >> >>
>> >>>>> > > >> >> -Alex
>> >>>>> > > >> >>
>> >>>>> > > >> >> On 11/13/14, 10:49 AM, "mark goldin"
>> >>>>><markzolo...@gmail.com>
>> >>>>> > wrote:
>> >>>>> > > >> >>
>> >>>>> > > >> >> >No, they are not static. I even replaces public var ...
>> >>>>>with
>> >>>>> > setter
>> >>>>> > > >>and
>> >>>>> > > >> >> >getter. Still the same.
>> >>>>> > > >> >> >Here more code for singleton:
>> >>>>> > > >> >> >public var data:Object;
>> >>>>> > > >> >> >public function
>>ModelLocator(enforcer:SingletonEnforcer)
>> >>>>> > > >> >> >{
>> >>>>> > > >> >> >if (enforcer == null){
>> >>>>> > > >> >> >throw new Error("You can have only one ModelLocator");
>> >>>>> > > >> >> >}
>> >>>>> > > >> >> >}
>> >>>>> > > >> >> > public static function getInstance():ModelLocator{
>> >>>>> > > >> >> > if (_instance == null){
>> >>>>> > > >> >> >_instance = new ModelLocator(new SingletonEnforcer());
>> >>>>> > > >> >> > }
>> >>>>> > > >> >> > return _instance;
>> >>>>> > > >> >> > }
>> >>>>> > > >> >> >class SingletonEnforcer{}
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >In another class I am getting an instance of singleton:
>> >>>>> > > >> >> >private var _model:ModelLocator =
>> >>>>>ModelLocator.getInstance();
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >BindingUtils.bindSetter(onDataLoaded, _Model.data,
>> >>>>> "propOnData");
>> >>>>> > > >> >> >new GetDataEvent().dispatch();
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >public function onDataLoaded(value:String):void
>> >>>>> > > >> >> >{
>> >>>>> > > >> >> >trace(2);
>> >>>>> > > >> >> >if (value)
>> >>>>> > > >> >> >{
>> >>>>> > > >> >> >......
>> >>>>> > > >> >> >}
>> >>>>> > > >> >> >}
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >this is a command that set to get data when
>>GetDataEvent
>> >>>>> event is
>> >>>>> > > >> >> >triggered:
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >public function result(data:Object):void
>> >>>>> > > >> >> >{
>> >>>>> > > >> >> >var re:ResultEvent = data as ResultEvent;
>> >>>>> > > >> >> >_assetHealthModel.data = re.result as Object;
>> >>>>> > > >> >> >trace(1);
>> >>>>> > > >> >> >}
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >In Console I see
>> >>>>> > > >> >> >2
>> >>>>> > > >> >> >1
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >but never 2 again.
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >Hope, it's clear.
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >Thanks
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >On Thu, Nov 13, 2014 at 12:37 PM, Alex Harui <
>> >>>>> aha...@adobe.com>
>> >>>>> > > >>wrote:
>> >>>>> > > >> >> >
>> >>>>> > > >> >> >>
>> >>>>> > > >> >> >>
>> >>>>> > > >> >> >> On 11/13/14, 10:04 AM, "mark goldin" <
>> >>>>> markzolo...@gmail.com>
>> >>>>> > > >>wrote:
>> >>>>> > > >> >> >>
>> >>>>> > > >> >> >> >Here is singleton definition:
>> >>>>> > > >> >> >> >[Bindable]
>> >>>>> > > >> >> >> >public class ModelLocator extends EventDispatcher
>> >>>>> implements
>> >>>>> > > >> >> >>IModelLocator
>> >>>>> > > >> >> >> >
>> >>>>> > > >> >> >> >All properties on that class are public vars.
>> >>>>> > > >> >> >>
>> >>>>> > > >> >> >> I’ll assume you are trying to tell me that they are
>>not
>> >>>>> public
>> >>>>> > > >>static
>> >>>>> > > >> >> >>vars?
>> >>>>> > > >> >> >>
>> >>>>> > > >> >> >> When we’ll need to know more about how the instance
>>is
>> >>>>> shared,
>> >>>>> > > >> >>whether
>> >>>>> > > >> >> >>you
>> >>>>> > > >> >> >> are getting warnings and compile time or runtime, and
>> >>>>> probably
>> >>>>> > > >>more
>> >>>>> > > >> >> >> details about what the symptoms are.
>> >>>>> > > >> >> >>
>> >>>>> > > >> >> >> -Alex
>> >>>>> > > >> >> >>
>> >>>>> > > >> >> >>
>> >>>>> > > >> >>
>> >>>>> > > >> >>
>> >>>>> > > >>
>> >>>>> > > >>
>> >>>>> > >
>> >>>>> > >
>> >>>>> >
>> >>>>>
>> >>>>
>> >>>>
>> >>>
>> >>
>>
>>

Reply via email to