memory allocation - implementation details??

Discussion in 'Perl' started by Ozgun Erdogan, Aug 13, 2004.

  1. Hi all -

    So, I have a huge program with these lines added somewhere in the
    program:

    test_circular_ref {
    my %x = ();
    my %y = ();
    $x{child} = \%y;
    $y{parent} = \%x;
    }

    I'm doing shared object hijacking (with LD_PRELOAD), and am
    intercepting uproot_SV(p) (I know this is a macro), and
    Perl_sv_free(SV *sv).

    For each variable that's not freed, I'm walking over all of its
    elements, check if there are references, and if there are, I walk over
    them too. If I come over to anything I've seen before, I declare a
    circular reference. At that point, I print out stack traces for where
    "each variable and their referees are allocated" (as I was
    intercepting uproot_SV(p) too).

    This works great on the first call to test_circular_ref. The problem
    arises on the second call to test_circular_ref. For some reason, on
    the second call, $x{child} and $y{parent} are allocated again (which
    makes sense), but not the hashes themselves. This seems really weird
    to me, and it feels like Perl is bypassing mallocs for arrays and
    hashes.

    Any ideas about what may be going on would really be appreciated.

    Ozgun.
    Ozgun Erdogan, Aug 13, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    Show Details/Hide Details link button

    =?Utf-8?B?Sm9l?=, Mar 13, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    904
    dkode
    Mar 13, 2006
  2. s.subbarayan

    Dynamic memory allocation and memory leak...

    s.subbarayan, Mar 18, 2005, in forum: C Programming
    Replies:
    10
    Views:
    696
    Eric Sosman
    Mar 22, 2005
  3. Ken
    Replies:
    24
    Views:
    3,857
    Ben Bacarisse
    Nov 30, 2006
  4. chris
    Replies:
    6
    Views:
    986
    chris
    Oct 28, 2005
  5. Bjarke Hammersholt Roune
    Replies:
    14
    Views:
    1,181
    Bjarke Hammersholt Roune
    Mar 6, 2011
Loading...

Share This Page