]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Extra memory usage instrumentation added. (CVS 2553)
authordrh <drh@noemail.net>
Wed, 20 Jul 2005 14:31:53 +0000 (14:31 +0000)
committerdrh <drh@noemail.net>
Wed, 20 Jul 2005 14:31:53 +0000 (14:31 +0000)
FossilOrigin-Name: ac669f56c0759a7e3eaa6f0018c8fb9d614e7d69

manifest
manifest.uuid
src/test1.c
src/util.c

index f63464223e524b496f943584364154d9b0f9c35a..9484f523dd3d809f53cb5920cbb5665dc2be8a27 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C More\srefactoring\sin\swhere.c.\s(CVS\s2552)
-D 2005-07-19T22:22:13
+C Extra\smemory\susage\sinstrumentation\sadded.\s(CVS\s2553)
+D 2005-07-20T14:31:53
 F Makefile.in 22ea9c0fe748f591712d8fe3c6d972c6c173a165
 F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -67,7 +67,7 @@ F src/sqlite.h.in 838382ed6b48d392366a55e07f49d9d71263e1fe
 F src/sqliteInt.h 97d50f5714a5f5a8190b871305e33a96c4638a8a
 F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9
 F src/tclsqlite.c cccaf6b78c290d824cf8ea089b8b27377e545830
-F src/test1.c 1dea8df4abb846cb3a2ce8a6e13d8b32dbd31b16
+F src/test1.c 722c1444b5774705eb6eb11163343fc94ffe17f7
 F src/test2.c 716c1809dba8e5be6093703e9cada99d627542dc
 F src/test3.c 683e1e3819152ffd35da2f201e507228921148d0
 F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df
@@ -76,7 +76,7 @@ F src/tokenize.c 57ec9926612fb9e325b57a141303573bc20c79bf
 F src/trigger.c f51dec15921629591cb98bf2e350018e268b109a
 F src/update.c 49a9c618c3ba1ca57038d9ce41f14e958442fe58
 F src/utf.c bda5eb85039ef16f2d17004c1e18c96e1ab0a80c
-F src/util.c 1acbe299cbe51f45176ac1e48ded9bea206c3c23
+F src/util.c 668d31be592753e5b8ea00e69ea8d3eedb29fa22
 F src/vacuum.c 829d9e1a6d7c094b80e0899686670932eafd768c
 F src/vdbe.c 7b41a1979d3421dbbe34a3a48970b4e75fb1d634
 F src/vdbe.h 75e466d84d362b0c4498978a9d6b1e6bd32ecf3b
@@ -286,7 +286,7 @@ F www/tclsqlite.tcl 425be741b8ae664f55cb1ef2371aab0a75109cf9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b
-P 57c6bd3760163c174be4a2ece58f414e82b55938
-R 3cdcdb6928aa7a2c42a275a913941b5a
+P a35bd50af8961133adc66e40c38402e81a02bb56
+R 73dbc3e4bd94a516434db925353f0d59
 U drh
-Z b929286800f2e064fa91faa90163e11f
+Z b94984498572a6b7851afac6f92deee0
index 20ef12eab7190a84753d12f6b6f5a8116a255c42..36a376c70b4b510f8b797841ee36dbb548ce8538 100644 (file)
@@ -1 +1 @@
-a35bd50af8961133adc66e40c38402e81a02bb56
\ No newline at end of file
+ac669f56c0759a7e3eaa6f0018c8fb9d614e7d69
\ No newline at end of file
index 1b9ecd6a09c7bde876be2ab1d4081e31ace532a6..ae609edee08cf2065daa95170830324eeb13aaba 100644 (file)
@@ -13,7 +13,7 @@
 ** is not included in the SQLite library.  It is used for automated
 ** testing of the SQLite library.
 **
-** $Id: test1.c,v 1.149 2005/07/15 23:24:24 drh Exp $
+** $Id: test1.c,v 1.150 2005/07/20 14:31:53 drh Exp $
 */
 #include "sqliteInt.h"
 #include "tcl.h"
@@ -3093,6 +3093,8 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
   extern int sqlite3_os_trace;
   extern int sqlite3_sync_count, sqlite3_fullsync_count;
   extern int sqlite3_opentemp_count;
+  extern int sqlite3_memUsed;
+  extern int sqlite3_memMax;
   extern char sqlite3_query_plan[];
   static char *query_plan = sqlite3_query_plan;
 
@@ -3115,6 +3117,10 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
       (char*)&sqlite3_current_time, TCL_LINK_INT);
   Tcl_LinkVar(interp, "sqlite_os_trace",
       (char*)&sqlite3_os_trace, TCL_LINK_INT);
+  Tcl_LinkVar(interp, "sqlite_memused",
+      (char*)&sqlite3_memUsed, TCL_LINK_INT | TCL_LINK_READ_ONLY);
+  Tcl_LinkVar(interp, "sqlite_memmax",
+      (char*)&sqlite3_memMax, TCL_LINK_INT | TCL_LINK_READ_ONLY);
   Tcl_LinkVar(interp, "sqlite_query_plan",
       (char*)&query_plan, TCL_LINK_STRING|TCL_LINK_READ_ONLY);
 #ifndef SQLITE_OMIT_DISKIO
index 2f33a1120d5456526079a3cc0bbab2e8a37b9231..18b5ada24754c4a1a295a650f60795e17e17cca1 100644 (file)
@@ -14,7 +14,7 @@
 ** This file contains functions for allocating memory, comparing
 ** strings, and stuff like that.
 **
-** $Id: util.c,v 1.140 2005/06/29 17:24:24 drh Exp $
+** $Id: util.c,v 1.141 2005/07/20 14:31:53 drh Exp $
 */
 #include "sqliteInt.h"
 #include <stdarg.h>
@@ -58,6 +58,8 @@ int sqlite3_malloc_failed = 0;
 */
 int sqlite3_nMalloc;         /* Number of sqliteMalloc() calls */
 int sqlite3_nFree;           /* Number of sqliteFree() calls */
+int sqlite3_memUsed;         /* Total memory obtained from malloc */
+int sqlite3_memMax;          /* Mem usage high-water mark */
 int sqlite3_iMallocFail;     /* Fail sqliteMalloc() after this many calls */
 int sqlite3_iMallocReset = -1; /* When iMallocFail reaches 0, set to this */
 #if SQLITE_MEMDEBUG>1
@@ -92,6 +94,8 @@ void *sqlite3Malloc_(int n, int bZero, char *zFile, int line){
     }
   }
   if( n==0 ) return 0;
+  sqlite3_memUsed += n;
+  if( sqlite3_memMax<sqlite3_memUsed ) sqlite3_memMax = sqlite3_memUsed;
   k = (n+sizeof(int)-1)/sizeof(int);
   pi = malloc( (N_GUARD*2+1+k)*sizeof(int));
   if( pi==0 ){
@@ -157,6 +161,7 @@ void sqlite3Free_(void *p, char *zFile, int line){
       }
     }
     n = pi[N_GUARD];
+    sqlite3_memUsed -= n;
     k = (n+sizeof(int)-1)/sizeof(int);
     for(i=0; i<N_GUARD; i++){
       if( pi[k+N_GUARD+1+i]!=0xdead3344 ){
@@ -195,6 +200,7 @@ void *sqlite3Realloc_(void *oldP, int n, char *zFile, int line){
     return 0;
   }
   oldN = oldPi[N_GUARD];
+  sqlite3_memUsed -= oldN;
   oldK = (oldN+sizeof(int)-1)/sizeof(int);
   for(i=0; i<N_GUARD; i++){
     if( oldPi[oldK+N_GUARD+1+i]!=0xdead3344 ){
@@ -211,6 +217,8 @@ void *sqlite3Realloc_(void *oldP, int n, char *zFile, int line){
   }
   for(i=0; i<N_GUARD; i++) pi[i] = 0xdead1122;
   pi[N_GUARD] = n;
+  sqlite3_memUsed += n;
+  if( sqlite3_memMax<sqlite3_memUsed ) sqlite3_memMax = sqlite3_memUsed;
   for(i=0; i<N_GUARD; i++) pi[k+N_GUARD+1+i] = 0xdead3344;
   p = &pi[N_GUARD+1];
   memcpy(p, oldP, n>oldN ? oldN : n);