Opened 10 years ago

Closed 9 years ago

#4058 closed defect (needs_more_info)

Memory leak with recording from IP-cameras in separate threads

Reported by: xaruch Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: leak
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Hello all!
I've got a program that recording video from IP-cameras. Because to cameras quantity is quite many I using pthreads. Also video from cameras splitting to fragments with some length (for ex., 300 seconds).

But I have got a big problem: memory definitely leaks after each time cycle.

For debug purposes I create simplified prototype project. Full code for it can be found this GIT repository: https://github.com/xaruch/ffmpeg_tests

Memory increasing diagram:
http://www.datafilehost.com/d/b2cba5ea
Vertical axis is VmRss for test program pid with 1 seconds step.
Horizontal axis is time.

The main cycle:

	if (PWriter->TimerCounter >= REC_TIMEOUT)
	{
		uint64_t mem = PWriter->GetMemoryConsumption();
		sprintf(str, "DEBUG: Timeout callback. Memory: %lld. Delta: %lld\n", mem, mem - Memory);
		AppendLog(str, "MAIN");
		Memory = mem;
		PWriter->TimerCounter = 0;
		PWriter->Continue();
	}

Start recording called from this function:

int FfPipeline::ThInitiateRecording()
{
  const char *class_name = "FfPipeline::ThInitiateRecording";
  pthread_t ptid;

  sprintf(str, "DEBUG: Pipeline slot '%d'. Try to starting thread with stopping...\n", Slot);
  AppendLog(str, class_name);

  pthread_create(&ptid, NULL, &ThRecording, (void *) this);

  pthread_detach(ptid);

  sprintf(str, "DEBUG: Pipeline slot '%d'. Starting thread ended!\n", Slot);
  AppendLog(str, class_name);

  return 0;
}

Attachments (2)

mem_leak.png (14.9 KB ) - added by xaruch 10 years ago.
Memory leak diagram
valgrind_27.10.2014_18.58.log (32.7 KB ) - added by xaruch 10 years ago.
Valgrind log for memory leak

Download all attachments as: .zip

Change History (10)

by xaruch, 10 years ago

Attachment: mem_leak.png added

Memory leak diagram

comment:1 by xaruch, 10 years ago

libavcodec.so.56.1.100
libavdevice.so.56.0.100
libavfilter.so.5.1.100
libavformat.so.56.4.101
libavutil.so.54.7.100
libswresample.so.1.1.100
libswscale.so.3.0.100

comment:2 by Carl Eugen Hoyos, 10 years ago

Keywords: memory pthreas removed

Please test current FFmpeg git head and please provide valgrind output for memory leaks.

by xaruch, 10 years ago

Valgrind log for memory leak

in reply to:  2 comment:3 by xaruch, 10 years ago

Replying to cehoyos:

Please test current FFmpeg git head and please provide valgrind output for memory leaks.

I am attach valgrind log for running test program with last FFmpeg git head.

comment:4 by xaruch, 10 years ago

Please suggest any ideas!

comment:5 by Carl Eugen Hoyos, 9 years ago

Please recompile with --disable-stripping to make the valgrind output useful.

comment:6 by xaruch, 9 years ago

This is great!
No leaks after recompilation with this option. But I want to undestand what's this options means and how to link to memory leakage in project?

comment:7 by Carl Eugen Hoyos, 9 years ago

The option is not related to the memory leaks at all.

Your valgrind output was missing nearly all useful information because your libraries did not contain debug information (which is the default to make the libraries smaller). Recompiling with --disable-stripping allows the valgrind output to contain more information.

comment:8 by Carl Eugen Hoyos, 9 years ago

Resolution: needs_more_info
Status: newclosed
Version: 2.4.2unspecified

Please reopen if you can provide a useful valgrind output (one with --disable-stripping) that shows a memleak.

Note: See TracTickets for help on using tickets.