Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
you can see my reasoning on reference count and I dont really see anything wrong with it, do you?

Yes. You assert:

6. D goes out of scope, reference count for D drops to 0 and D is extinguished

I showed that what actually happens is more like:

6. D goes out of scope. Nothing happens.
N. (Much later) Global destruction finally fires and a bunch of stuff finally gets destroyed, forcibly breaking the circular references

my fix does indeed prevent a bunch of stuff from being cleaned up until Perl's "global destruction". which is fine with me. [emphasis added]

So you don't care about making circular references? The consequence of making circular references is that destructors don't fire until global destruction. You don't appear to understand that.

Some reasons why I don't find acceptable the delaying of destruction until global destruction (and thus circular references) include:

During global destruction, proper order of destruction is not enforced, which can lead to an object being destroyed after an object that it depends on has already been destroyed. This can produce obnoxious warnings, increase the complexity of destruction code, or just make proper clean-up not reliably possible.

It also means that a long-running process that ends up making multiple connections to a database (for example) will "leak memory" or even leak other resources (like hording open file handles).

It can also delay or even prevent the flushing of data. It can also delay the detection and reporting of bugs like a user forgetting to "finish" some operation. In some environments, delaying such reporting until global destruction can easily effectively make such reporting useless.

Did you demonstrate that my patch creates circular references?

Do you have some alternate theory as to why destruction gets delayed until global destruction? The simple, obvious explanation is that the extra reference that your "fix" creates produces a cycle. I didn't provide detailed documentation of the exact nature of the cycle, but stuff not getting destroyed when everything related to it has gone out of scope is pretty convincing evidence of the cycle existing in this case.

Are you implying that my method chaining and the resulting destruction was unsound?

Rather than implying it, I thought I stated it quite explicitly:

you should simply stop writing code that destroys the container object if you want to keep using one of the contained objects

Yes, it is "unsound" to make the controller object a temporary throw-away that does not live long enough for you to finish using the subordinate object that you got from it (if the subordinate object's life cycle is supposed to be limited to within the controller's life cycle, as is the case here).

- tye        


In reply to Re^7: How should a fork of DBIx::Simple be handled? (selective comprehension) by tye
in thread How should a fork of DBIx::Simple be handled? by metaperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-19 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found