Opened 5 years ago

Closed 5 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 5 years ago.
Memory leak diagram
valgrind_27.10.2014_18.58.log (32.7 KB) - added by xaruch 5 years ago.
Valgrind log for memory leak

Download all attachments as: .zip

Change History (10)

Changed 5 years ago by xaruch

Memory leak diagram

comment:1 Changed 5 years ago by xaruch

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 follow-up: Changed 5 years ago by cehoyos

  • Keywords memory pthreas removed

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

Changed 5 years ago by xaruch

Valgrind log for memory leak

comment:3 in reply to: ↑ 2 Changed 5 years ago by xaruch

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 Changed 5 years ago by xaruch

Please suggest any ideas!

comment:5 Changed 5 years ago by cehoyos

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

comment:6 Changed 5 years ago by xaruch

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 Changed 5 years ago by cehoyos

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 Changed 5 years ago by cehoyos

  • Resolution set to needs_more_info
  • Status changed from new to closed
  • Version changed from 2.4.2 to unspecified

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.