04.11.14 20:00, Dan Dennedy написав(ла):
On Tue, Nov 4, 2014 at 12:19 AM, Maksym Veremeyenko <ve...@m1stereo.tv
<mailto:ve...@m1stereo.tv>> wrote:

    Hi,

    during mem leak search i found that dumping pool state is helpfull,
    so i cutted pool stat code into separate function

    Subject: [PATCH] implement mlt_pool_stat

    diff --git a/src/framework/mlt.vers b/src/framework/mlt.vers
    index 7c4a22c..bf273b1 100644
    --- a/src/framework/mlt.vers
    +++ b/src/framework/mlt.vers
    @@ -219,6 +219,7 @@ MLT_0.8.8 {
          mlt_pool_purge;
          mlt_pool_realloc;
          mlt_pool_release;
    +    mlt_pool_stat;
          mlt_producer_attach;
          mlt_producer_clear;
          mlt_producer_close;


You are not allowed to modify the symbols of an old version. You must
make a new block for the next version (MLT_0.9.4) that extends the
current version (MLT_0.9.2). Odd-numbered interim version numbers are
not used here.

    +mlt_log( NULL, MLT_LOG_VERBOSE, "%s: count %d\n", __FUNCTION__, c);


Since you have to resubmit patch 0001, please use the preferred format
of logging calls: mlt_log_verbose(). Yes, I realize other parts of the
code are using mlt_log(), but I want new/changed code to use the
preferred, more succinct format.

    Subject: [PATCH 2/3] descrease allocated pool items counter after
    purging it


Please correct the spelling error (decrease) and if you use a sentence,
which is preferred, then do capitalize the first word and end with a
period. I am willing to correct those if that is the only thing wrong in
the patch, as is the case here.

    Subject: [PATCH 3/3] calculate total bytes allocated and used by
    mlt_pool

    +mlt_log( NULL, MLT_LOG_VERBOSE, "%s: allocated %"PRId64" bytes,
    used %"PRId64" bytes \n",


Use sentence for commit message and use mlt_log_verbose().

i updated patches. please review

--
________________________________________
Maksym Veremeyenko
>From f4cf7c9380539ffcf6d4abc94f0dcbc3c8e02717 Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <ve...@m1.tv>
Date: Mon, 24 Nov 2014 19:53:38 +0200
Subject: [PATCH 1/3] Implement mlt_pool_stat.

---
 src/framework/mlt.vers   |    4 ++++
 src/framework/mlt_pool.c |   25 ++++++++++++++++---------
 src/framework/mlt_pool.h |    1 +
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/framework/mlt.vers b/src/framework/mlt.vers
index 7c4a22c..34254f4 100644
--- a/src/framework/mlt.vers
+++ b/src/framework/mlt.vers
@@ -455,3 +455,7 @@ MLT_0.9.2 {
     mlt_properties_time_to_frames;
     mlt_properties_from_utf8;
 } MLT_0.9.0;
+
+MLT_0.9.4 {
+    mlt_pool_stat;
+} MLT_0.9.2;
diff --git a/src/framework/mlt_pool.c b/src/framework/mlt_pool.c
index 9793a88..0bb3d3f 100644
--- a/src/framework/mlt_pool.c
+++ b/src/framework/mlt_pool.c
@@ -388,19 +388,26 @@ void mlt_pool_release( void *release )
 void mlt_pool_close( )
 {
 #ifdef _MLT_POOL_CHECKS_
-	// Stats dump on close
-	int i = 0;
-	for ( i = 0; i < mlt_properties_count( pools ); i ++ )
+	mlt_pool_stat( );
+#endif
+
+	// Close the properties
+	mlt_properties_close( pools );
+}
+
+void mlt_pool_stat( )
+{
+	// Stats dump
+	int i = 0, c = mlt_properties_count( pools );
+
+	mlt_log( NULL, MLT_LOG_VERBOSE, "%s: count %d\n", __FUNCTION__, c);
+
+	for ( i = 0; i < c; i ++ )
 	{
 		mlt_pool pool = mlt_properties_get_data_at( pools, i, NULL );
 		if ( pool->count )
-			mlt_log( NULL, MLT_LOG_DEBUG, "%s: size %d allocated %d returned %d %c\n", __FUNCTION__,
+			mlt_log_verbose( NULL, "%s: size %d allocated %d returned %d %c\n", __FUNCTION__,
 				pool->size, pool->count, mlt_deque_count( pool->stack ),
 				pool->count !=  mlt_deque_count( pool->stack ) ? '*' : ' ' );
 	}
-#endif
-
-	// Close the properties
-	mlt_properties_close( pools );
 }
-
diff --git a/src/framework/mlt_pool.h b/src/framework/mlt_pool.h
index fa1f5cb..4ca1f12 100644
--- a/src/framework/mlt_pool.h
+++ b/src/framework/mlt_pool.h
@@ -29,5 +29,6 @@ extern void *mlt_pool_realloc( void *ptr, int size );
 extern void mlt_pool_release( void *release );
 extern void mlt_pool_purge( );
 extern void mlt_pool_close( );
+extern void mlt_pool_stat( );
 
 #endif
-- 
1.7.7.6

>From 116821c697570d2eef94ba784a373b57188dee17 Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <ve...@m1.tv>
Date: Mon, 24 Nov 2014 19:56:04 +0200
Subject: [PATCH 2/3] Decrease allocated pool items counter after purging it.

---
 src/framework/mlt_pool.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/framework/mlt_pool.c b/src/framework/mlt_pool.c
index 0bb3d3f..6f479b2 100644
--- a/src/framework/mlt_pool.c
+++ b/src/framework/mlt_pool.c
@@ -361,7 +361,10 @@ void mlt_pool_purge( )
 
 		// We'll free all unused items now
 		while ( ( release = mlt_deque_pop_back( self->stack ) ) != NULL )
+		{
 			mlt_free( ( char * )release - sizeof( struct mlt_release_s ) );
+			self->count--;
+		}
 
 		// Unlock the pool
 		pthread_mutex_unlock( &self->lock );
-- 
1.7.7.6

>From 563a24fe72e2f84a89bb0753ec9f017ff0c3011a Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <ve...@m1.tv>
Date: Mon, 24 Nov 2014 20:00:28 +0200
Subject: [PATCH 3/3] Calculate total bytes allocated and used by mlt_pool.

---
 src/framework/mlt_pool.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/framework/mlt_pool.c b/src/framework/mlt_pool.c
index 6f479b2..49bc507 100644
--- a/src/framework/mlt_pool.c
+++ b/src/framework/mlt_pool.c
@@ -401,6 +401,7 @@ void mlt_pool_close( )
 void mlt_pool_stat( )
 {
 	// Stats dump
+	int64_t allocated = 0, used = 0;
 	int i = 0, c = mlt_properties_count( pools );
 
 	mlt_log( NULL, MLT_LOG_VERBOSE, "%s: count %d\n", __FUNCTION__, c);
@@ -412,5 +413,10 @@ void mlt_pool_stat( )
 			mlt_log_verbose( NULL, "%s: size %d allocated %d returned %d %c\n", __FUNCTION__,
 				pool->size, pool->count, mlt_deque_count( pool->stack ),
 				pool->count !=  mlt_deque_count( pool->stack ) ? '*' : ' ' );
+		allocated += pool->count * pool->size;
+		used += ( pool->count - mlt_deque_count( pool->stack ) ) * pool->size;
 	}
+
+	mlt_log_verbose( NULL, "%s: allocated %"PRId64" bytes, used %"PRId64" bytes \n",
+		__FUNCTION__, allocated, used );
 }
-- 
1.7.7.6

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to