Axel Schmidt (axel++at++artcom.de)
Wed, 27 Aug 1997 18:00:00 +0200
Attribute arrays of a pfGeoSet not unrefed/deleted after
deletion of the pfGeoSet using pfDelete(). The pfGeoSet
manpage says:
...
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.
...
A workaround for this bug is using pfMemory::checkDelete()
instead of pfDelete() and everthing works like expected.
But what workaround exists for pfAsyncDelete(), which have the same
bug as pfDelete()? (I've tested it with a lot of pfFrame()s to force
the deletion)
As I now, pfDelete() uses pfBuffer::checkDelete(). What
is the difference between pfBuffer::checkDelete() and
pfMemory::checkDelete()?
The following code demonstrates, what I mean.
Axel.
----------------------------------------------------
//
// Compile with: CC -o pfDeleteTest pfDeleteTest.c++ -lpf -lfpe
//
// Test using pfDelete():
//
// pfDeleteTest
//
// Test using pfMemory::checkDelete():
//
// pfDeleteTest Du musst Amboss oder Hammer sein
//
#include <Performer/pr/pfGeoSet.h>
#include <Performer/pf/pfGeode.h>
main(int ac, char** av)
{
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) {
retval = pfUnrefDelete(gset);
fprintf(stderr, "after
pfUnrefDelete(gset)==%d: coord-rc(%d) <- should
be 1\n", retval, pfMemory::getMemory(coord)->getRef());
} else {
retval = pfMemory::unrefDelete(gset);
fprintf(stderr, "after unrefDelete(gset)==%d
: coord-rc(%d) <- should be 1\n", retval,
pfMemory::getMemory(coord)->getRef());
}
}
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:55:47 PDT