Re: pfDelete bug

New Message Reply Date view Thread view Subject view Author view

Axel Schmidt (axel++at++artcom.de)
Mon, 01 Sep 1997 19:52:50 +0200


Hi Marcus:

Thanks for your answer. I am afraid I was unable to state
my problem sufficiently clear. So once again:

As the test program from my last mail demonstrated,
pfDelete doesn't have immediate effect on attribute arrays
of a pfGeoSet. Only the geoset reference count is
decremented immediately, while the attr-array is
decremented not before the 4th pfFrame call. This is
demonstrated in the below test program. According to the
manual page, this behaviour would be expected only for
pfAsyncDelete.

Excerpt from the manpage:
    (from pfGeoSet)
    ...
    When a pfGeoSet is deleted with pfDelete, all pfMalloc'ed
    lists will have their reference counts decremented by one
    and will be freed if their count reaches 0.
    ...
    (from pfBuffer)
    ...
    pfAsyncDelete is a special version of pfDelete which is useful for
    asynchronous database deletion. Instead of having immediate effect,
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    pfAsyncDelete simply registers a deletion request at the time of
    invocation.
    ...

Thus, I suggest to clarify the behaviour of pfDelete in the manual page.
Also, a reference to "pfMemory::checkDelete" for an immediate deletion
of all children would be extermely helpful.
I personally could have saved some hours of debugging.

Regards.

//
// Compile with: CC -o pfDeleteTest pfDeleteTest.c++ -lpf
-lfpe
// type "pfDeleteTest": demonstrates delayed deletion of geoset's
attribute list.
// type "pfDeleteTest x": demonstrates immediate deletion of geoset's
attribute list.
//

#include <Performer/pr/pfGeoSet.h>
#include <Performer/pf/pfGeode.h>

main(int ac, char** av)
{
    pfNotifyLevel(0);
    pfInit();
    pfMultiprocess(PFMP_APPCULLDRAW); // no mp
    pfConfig();

    pfGeode* geode = new pfGeode();

    pfGeoSet* gset = new pfGeoSet();
    gset->ref(); // ref, so we can check if refcount is decremented
after geode was deleted

    pfVec3* coord = (pfVec3*)pfMalloc(3 * sizeof(pfVec3),
pfGetSharedArena());
    pfMemory::getMemory(coord)->ref(); // ref, so we can check if
refcount was decremented
                                       // after geoset was deleted

    gset->setAttr(PFGS_COORD3, PFGS_PER_VERTEX, coord, 0);
    gset->setPrimType(PFGS_TRIS);
    gset->setNumPrims(1);

    geode->addGSet(gset);

    int retval;
    fprintf(stderr, "before any deletion : geode-rc=%d gset-rc=%d
coord-rc=%d\n", geode->getRef(), gset->getRef(),
pfMemory::getMemory(coord)->getRef());
    if (ac == 1) {
        retval = pfDelete(geode);
        fprintf(stderr, "after pfDelete(geode)==%d :
gset-rc=%d coord-rc=%d\n", retval, gset->getRef(),
pfMemory::getMemory(coord)->getRef());
    } else {
        retval = pfMemory::checkDelete(geode);
        fprintf(stderr, "after checkDelete(geode)==%d:
gset-rc=%d coord-rc=%d\n", retval, gset->getRef(),
pfMemory::getMemory(coord)->getRef());
    }
    if (ac == 1) {
        gset->unref();
        fprintf(stderr, "after gset.unref() :
gset-rc=%d coord-rc=%d\n", gset->getRef(),
pfMemory::getMemory(coord)->getRef());
        retval = pfDelete(gset);
        fprintf(stderr, "after pfDelete(gset)==%d
: coord-rc=%d (should be 1)\n", retval,
pfMemory::getMemory(coord)->getRef());
        for (int i = 1; pfMemory::getMemory(coord)->getRef() > 1; i++) {
            pfFrame();
            fprintf(stderr, "after %d pfFrame()
: coord-rc=%d (should be 1)\n", i,
pfMemory::getMemory(coord)->getRef());
        }
    } else {
        gset->unref();
        retval = pfMemory::checkDelete(gset);
        fprintf(stderr, "after checkDelete(gset)==%d
: coord-rc=%d (should be 1)\n", retval,
pfMemory::getMemory(coord)->getRef());
    }

}

--
Axel Schmidt      axel++at++artcom.de           fon +49-30-254 17 3
ART+COM Berlin    http://www.artcom.de/    fax +49-30-254 17 555
=======================================================================
List Archives, FAQ, FTP:  http://www.sgi.com/Technology/Performer/
            Submissions:  info-performer++at++sgi.com
        Admin. requests:  info-performer-request++at++sgi.com

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:55:50 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.