[Live-devel] Enumerate all 'clients' and memory leak

Звягинцев Антон zvyagintsev at atlantis.ru
Thu Sep 20 04:41:19 PDT 2012


Hello.

As far as I understand live555 keep track the created 'objects' in internal
containers so my guess was it is possible to iterate over that containers.

What I need is to enumerate all rtspclients. According to this comment 

 

// A data structure for looking up a Medium by its string name.

// (It is used only to implement "Medium", but we make it visible here, in
case developers want to use it to iterate over

//  the whole set of "Medium" objects that we've created.)

 

I used MediaLookupTable and my 'environment' pointer:

 

                MediaLookupTable* ptable =
MediaLookupTable::ourMedia(*pliveenvironment);

                HashTable const& objects = ptable->getTable();

 

                HashTable::Iterator* piterator =
HashTable::Iterator::create(objects);

 

                MediaSession* pmediasession;

                vector<MediaSession*> clients; // put here all found clients

                char const* key;

 

                while ( (pmediasession =
(MediaSession*)piterator->next(key)) != NULL )

                               if (pmediasession->isRTSPClient())

clients.push_back(pmediasession); // if it is RTSPClient put it to vector

 

                delete piterator;

 

This works, but later I noticed a memory leak in MediaLookupTable::ourMedia:

 

MediaLookupTable* MediaLookupTable::ourMedia(UsageEnvironment& env) {

  _Tables* ourTables = _Tables::getOurTables(env);

  if (ourTables->mediaTable == NULL) {

    // Create a new table to record the media that are to be created in

    // this environment:

    ourTables->mediaTable = new MediaLookupTable(env);

  }

  return ourTables->mediaTable;

}

 

My ptable pointer allocated in MediaLookupTable::ourMedia but never deleted,
and I can't delete it myself - the destructor is protected.

So, I think I am doing something wrong. Maybe another way exists to
enumerate all specific objects?

 

WBR

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120920/e6a3b99b/attachment.html>


More information about the live-devel mailing list