View Issue Details

IDProjectCategoryView StatusLast Update
0000513Ecere SDKcompilerpublic2014-07-11 18:12
Reporterjerome Assigned To 
PriorityhighSeverityfeatureReproducibilityhave not tried
Status newResolutionopen 
Target Version0.45 Ginkakuji 
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.

Relationships

related to 0000177 new eC String Solution 

Activities

nicktick

2014-01-24 02:57

reporter   ~0001155

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 {};

nicktick

2014-01-24 02:59

reporter   ~0001156

should comment the "delete t" in void ::test(int size).

jerome

2014-05-04 04:02

administrator   ~0001270

Last edited: 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.

jerome

2014-05-08 05:33

administrator   ~0001279

Once we've got reference counting, look at providing libgmp bindings again.

jerome

2014-05-08 07:53

administrator   ~0001280

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
2012-03-08 16:51 redj Target Version => 0.45 Ginkakuji
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