View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000513Ecere SDKcompilerpublic2010-07-28 15:092014-07-11 18:12
Reporterjerome 
Assigned To 
PriorityhighSeverityfeatureReproducibilityhave not tried
StatusnewResolutionopen 
PlatformOSOS Version
Product Version 
Target Version0.45 GinkakujiFixed in Version 
Summary0000513: More Consistent Reference Counting: Block Scope
DescriptionClass objects declaration-instantiated (non anonymous) within a local block will now start with a reference count of 1 (instead of 0 as it is right now).

At the end of the block's scope they will now get decref'ed.

This will make it a lot more consistent with struct objects, as well as with global and member object instantiations, and will take away many cases of having to explicitly deal with memory management.
TagsNo tags attached.
Attached Files

- Relationships
related to 0000177new eC String Solution 

-  Notes
(0001155)
nicktick (reporter)
2014-01-24 02:57

Add an example of the destructor of a class would never be called:

import "ecere"

class Form1 : Window
{
   caption = "Form1";
   background = formColor;
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   clientSize = { 576, 392 };

   bool OnCreate(void)
   {
      int i;
      for(i=1;i<=10;i++)
      {
         Test::test(10000000);
         printf("round %d\r\n\r\n",i);
         Sleep(1);
      }
      return true;
   }
}


class Test
{
  int _size;
  byte *p;
public:
  property int size
  {
     get{ return _size; }
     set{ _size = value; p = new byte[_size]; p[0]= 0xff;}
  }
  ~Test()
  {
     delete p; //would never be called now.
  }
  void ::test(int size)
  {
      Test t;
      t = Test{size = size};
      delete t;
  }
}

Form1 form1 {};
(0001156)
nicktick (reporter)
2014-01-24 02:59

should comment the "delete t" in void ::test(int size).
(0001270)
jerome (administrator)
2014-05-04 04:02
edited on: 2014-05-04 07:34

We may want to go with full reference counting, with the introduction of a special syntax to declare weak references (e.g. Object ^handle) as a way to avoid reference cycles.

(0001279)
jerome (administrator)
2014-05-08 05:33

Once we've got reference counting, look at providing libgmp bindings again.
(0001280)
jerome (administrator)
2014-05-08 07:53

Now re-considering the idea of full reference counting to instead stick to:

- Starting local ref count at 1 and auto deleting at the end of the scope
- Object object = { } // Make that start at ref count 1 as well
                      This would still require a delete object as it does now.
- PrintLn(Object { }) // Auto increfing/decrefing that as well
- Window { }.Modal() // that as well
- Adding struct destructors

- Issue History
Date Modified Username Field Change
2010-07-28 15:09 jerome New Issue
2010-07-29 15:29 jerome Relationship added child of 0000003
2010-07-29 15:29 jerome Relationship deleted child of 0000003
2010-07-29 15:30 jerome Relationship added child of 0000431
2012-03-08 16:51 redj Target Version => 0.45 Ginkakuji
2012-03-08 21:21 redj Relationship deleted child of 0000431
2012-03-29 07:50 redj Category => eC Compiling Tools
2012-03-29 07:50 redj Project @2@ => Ecere SDK
2013-04-25 09:43 jerome Target Version 0.45 Ginkakuji => 0.44.4 Strings
2014-01-24 02:57 nicktick Note Added: 0001155
2014-01-24 02:59 nicktick Note Added: 0001156
2014-05-04 04:02 jerome Note Added: 0001270
2014-05-04 07:34 jerome Note Edited: 0001270
2014-05-04 10:46 jerome Relationship added related to 0000177
2014-05-08 05:33 jerome Note Added: 0001279
2014-05-08 07:53 jerome Note Added: 0001280
2014-07-11 18:12 jerome Target Version 0.44.30 Strings => 0.45 Ginkakuji



Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker