[Live-devel] valgrind showing memory leaks in Indexer

john dicostanzo john95018 at gmail.com
Fri May 23 10:51:36 PDT 2014


HI Ross,

I have modified Indexer utility ( MPEG2TransportStreamIndexer.cpp ) to
delete all the dynamic objects.
Code:
#include <liveMedia.hh>
#include <BasicUsageEnvironment.hh>

void afterPlaying(void* clientData); // forward

UsageEnvironment* env;
char const* programName;

void usage() {
  *env << "usage: " << programName << " <transport-stream-file-name>\n";
  *env << "\twhere <transport-stream-file-name> ends with \".ts\"\n";
  exit(1);
}
 TaskScheduler* scheduler;
 FramedSource* input;
 FramedSource* indexer;
 MediaSink* output;

int main(int argc, char const** argv) {
  // Begin by setting up our usage environment:
  scheduler = BasicTaskScheduler::createNew();
  env = BasicUsageEnvironment::createNew(*scheduler);

  // Parse the command line:
  programName = argv[0];
  if (argc != 2) usage();

  char const* inputFileName = argv[1];
  // Check whether the input file name ends with ".ts":
  int len = strlen(inputFileName);
  if (len < 4 || strcmp(&inputFileName[len-3], ".ts") != 0) {
    *env << "ERROR: input file name \"" << inputFileName
     << "\" does not end with \".ts\"\n";
    usage();
  }

  // Open the input file (as a 'byte stream file source'):
  input = ByteStreamFileSource::createNew(*env, inputFileName,
TRANSPORT_PACKET_SIZE);
  if (input == NULL) {
    *env << "Failed to open input file \"" << inputFileName << "\" (does it
exist?)\n";
    exit(1);
  }

  // Create a filter that indexes the input Transport Stream data:
  indexer = MPEG2IFrameIndexFromTransportStream::createNew(*env, input);

  // The output file name is the same as the input file name, except with
suffix ".tsx":
  char* outputFileName = new char[len+2]; // allow for trailing x\0
  sprintf(outputFileName, "%sx", inputFileName);

  // Open the output file (for writing), as a 'file sink':
  output = FileSink::createNew(*env, outputFileName);
  if (output == NULL)
  {
      *env << "Failed to open output file \"" << outputFileName << "\"\n";
      exit(1);
  }

  // Start playing, to generate the output index file:
  *env << "Writing index file \"" << outputFileName << "\"...";
  output->startPlaying(*indexer, afterPlaying, NULL);

  env->taskScheduler().doEventLoop(); // does not return

  return 0; // only to prevent compiler warning
}

void afterPlaying(void* /*clientData*/) {
  *env << "...done\n";

   Medium::close(output);
   Medium::close(input);
   Medium::close(indexer);

   delete scheduler;
   env->reclaim();

  exit(0);
}


As you can see agterPlaying function, is it right way to delete all objects
because valgrind tool showing memory leaks at closing
of "indexer" object.

Leaks:
==29177==  80(16 direct,64 indirect) bytes in 1 block are definitely lost
in loss record 3 of 3
==29177== at 0x402BA13: operator new(unsigned int)(vg_replace_malloc.c:313)
==29177== by 0x8055B67: _Tables::getOurTables(
UsageEnvironment &,unsigned char)
==29177== by 0x6524B67: MediaLookupTables::ourMedia(UsageEnvironment)
==29177== by 0x5874C6A: Medium::close(UsageEnvironment &,char const *)
==29177== by 0x424CCB7: Medium::close(Medium*)
==29177== by 0x5345C67: FramedFilter::~FramedFilter()
==29177== by 0x5345C67:
MPEG2IFrameIndexFromTransportStream::~MPEG2IFrameIndexFromTransportStream()
==29177== by 0x5345C67: Medium::close(Medium*)

Thanks & Regards,
John


On Wed, May 21, 2014 at 10:29 PM, john dicostanzo <john95018 at gmail.com>wrote:

> Hi,
> I am using Live555 library for my vod server, vod server create index file
> and announce transport stream.
> For Indexing, I am using code as reference from
> MPEG2TransportStreamIndexer.cpp
> but when i close and delete all the dynamic objects,valgrind shows memory
> leaks on it.
>
> Leaks:
> ==29177==  80(16 direct,64 indirect) bytes in 1 block are definitely lost
> in loss record 3 of 3
> ==29177== at 0x402BA13: operator new(unsigned int)(vg_replace_malloc.c:313)
> ==29177== by 0x8055B67: _Tables::getOurTables(UsageEnvironment &,unsigned
> char)
> ==29177== by 0x6524B67: MediaLookupTables::ourMedia(UsageEnvironment)
> ==29177== by 0x5874C6A: Medium::close(UsageEnvironment &,char const *)
> ==29177== by 0x424CCB7: Medium::close(Medium*)
> ==29177== by 0x5345C67: FramedFilter::~FramedFilter()
> ==29177== by 0x5345C67:
> MPEG2IFrameIndexFromTransportStream::~MPEG2IFrameIndexFromTransportStream()
> ==29177== by 0x5345C67: Medium::close(Medium*)
>
> I don't know, why its creating new dynamic object in
> Medium::close(operator new(unsigned int)(vg_replace_malloc.c:313))
>
> Thanks,
> John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20140523/0d6a16b3/attachment.html>


More information about the live-devel mailing list