Memory not being freed - why?

New Message Reply Date view Thread view Subject view Author view

wrvo (WRVO++at++chevron.com)
Thu, 19 Feb 1998 15:27:19 -0800


Here is a small fragment of code, including all the nasty debug stuff that
I've been using to try to figure what's going on.
The routine is called in the PostDraw routine to clean up texture files that
are no longer needed. There is a list of textures
and a list of codes. At the appropriate times, the app process has found
that some textures are no longer needed and sets the code. They are deleted
here at the end of the draw process when they are no longer in use. The
class TextureFile simply inherits from pfTexture (according the manual on
how to subclass). All it does is keep track of the file that the texture
belongs to and reads the texture from the file into memory when needed. The
TextureFiles are created in shared memory and the, in this case, the program
is running as a single process.

Then main problem that I'm having is that the texture is not freed. The
statement at line 11 is true, showing that the reference count on the
texture is 1, then unrefDelete should delete the texture, but the return
value from the call is false, indicating that it did not delete it. The
reference count printed in line 14 is still 1.

Under what conditions does unrefDelete not actually delete the memory
(besides the obvious when the reference count is greater than 0? The
destructor in TextureFile is virtual but it is not being called.

Any help on this would be greatly appreciated.

Thanks, Bill Volz

1 void DataCache1D::cleanUp(void)
2 {
3 int draw_buf = (app_buf + 1) % nbuf;
4 short *code = (short*) code_buf->get(draw_buf);
5 pfList *files = (pfList*) files_buf->get(draw_buf);
6 TextureFile *c;
7 for(int i = 0;i < nx; i++) {
8 if(code[i] <= 1) {
9 c = (TextureFile *) files->get(i);
10 if(c) {
11 if(c->ref() == 1) cerr << "deleting i = " <<
i << endl;
12 if(c->isLoaded()) c->idle();
13 if(!c->unrefDelete()) cerr << "did
not delete " << i << endl;
14 cerr << "refcount is now " <<
c->ref() << endl;
15 files->set(i,0);
16 }
17 }
18 }
19 }

=======================================================================
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:56:48 PDT

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