Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Reference counting

2010-03-10
2013-06-03
  • Marc Schellens
    Marc Schellens
    2010-03-10

    The actual CVS version has now reference counting for pointer and object.
    It actually does not do anything yet, just prints out a message if a heap variable goes out of scope (becomes dangling).
    To make it also care for the actual cleanup is now a very little step. However, for a smooth transition I did not want to break the CVS version in case there are still some bugs.
    Please check it out and drop a note, if you find any inconsistency (i.e. a wrong or missing message)
    Note that an automatic garbadge collection allows a completely different coding style.
    Much easier and saver and fits much better to a language like GDL. The yet to be released IDL 8.0 seems to have it as well.
    Regards,
    Marc

     
  • Marc Schellens
    Marc Schellens
    2010-03-21

    UPDATE:
    Reference counting does now actually cleanup dangling heap variables.

     
  • Marc,

    1. Thanks! It's great to have it.

    2. I've added a test_gc.pro to the "make check" (just two examples with pointers for the moment)

    3. The "make check" (test_hist_2d.pro) revealed a bug - it works! :) :
    GDL> a =  & print, *a
    Out of scope (garbage collected): <PtrHeapVar1>
    % Invalid pointer: <Expression> <POINTER   (<PtrHeapVar1>)>
    % Execution halted at: $MAIN$         

    Best,
    Sylwester

     
  • Marc,

    It would be great to add to the warnings some information on the file/line where the reference count reaches zero. For example I get some garbage collection in the CMSV lib (or the GDL wrappers) but there's a substantial amount of code to look at to find the location of the leak.

    Best,
    Sylwester

     
  • Marc Schellens
    Marc Schellens
    2010-04-12

    Sylwester,
    good idea, now the top of the callstack routine is printed together with the line number.
    However this is not always be 100% precise. For example the last code line number is printed when the local variables are cleaned up upon subroutine return. The line number is not always set (0). But I think it will help.
    Regards,
    Marc