4 Replies Latest reply on Jun 22, 2012 4:20 PM by drkstr_1

    Anyway to clear CallResponder returned valueobjects for GC?

    RobX82

      Background:

      Flex 4.1

      PHP backend through Zend framework

      Utilizing the paging functionality new in Flex 4

       

      I have a search interface setup in Flex that the user can define some values and get a return set shown in the grid.  The problem is when profiling it would appear that the any previous searches returned valueobjects never get garbage collected. 

       

      So I was wondering if there is some way to clear/mark these valueobjects for garbage collection.

        • 2. Re: Anyway to clear CallResponder returned valueobjects for GC?
          gfbaggio9

          I am looking for the same think

          Have you found a solution?

           

          Thanks

          • 3. Re: Anyway to clear CallResponder returned valueobjects for GC?
            RobX82 Level 1

            No, I never did.  We have since moved away from all Flex development.

            • 4. Re: Anyway to clear CallResponder returned valueobjects for GC?
              drkstr_1 Level 4

              Here is my base service class which is intended to keep the memory footprint low. Just Extend it into a specific service implementation and call disconnect() after any return result.

               

              public class AbstractRemoteService

              {

               

                        public function AbstractRemoteService()

                        {

               

                        }

               

                        public var destination:String = "";

               

                        private var _remoteObject:RemoteObject;

               

                        protected function get remoteObject():RemoteObject

                        {

                                  if(!_remoteObject)

                                  {

                                            _remoteObject = new RemoteObject(this.destination);

                                  }

               

                                  return _remoteObject;

                        }

               

                        public function disconnect():void

                        {

                                  if(!_remoteObject)

                                            return;

               

                                  _remoteObject.disconnect();

                                  _remoteObject = null;

                        }

              }

               

              Example Implementation:

               

              public class ContentService extends AbstractRemoteService implements IContentService

              {

               

                        public function ContentService()

                        {

                                  super();

               

               

                                  this.destination = "content_service";

                        }

               

                        public function beginSection(classNumber:int, section:int):AsyncToken

                        {

                                  return this.remoteObject.beginSection(classNumber, section);

                        }

               

                        public function completeSection(classNumber:int, section:int):AsyncToken

                        {

                                  return this.remoteObject.completeSection(classNumber, section);

                        }

               

                        public function loadAssignments():AsyncToken

                        {

                                  return this.remoteObject.loadAssignment();

                        }

               

                        public function loadContent(courseID:int):AsyncToken

                        {

                                  return this.remoteObject.loadContent(courseID);

                        }

              }

               

              You can also add a Responder in the class itself to do this, but I prefer to call disconnect() externally (in the business logic layer), because there are instances where you do not want to automatically disconnect.