aboutsummaryrefslogtreecommitdiff
path: root/src/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/malloc.c')
-rw-r--r--src/malloc.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/malloc.c b/src/malloc.c
index 932cecc21..9a2eaeec1 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -211,6 +211,27 @@ sqlite3_int64 sqlite3_memory_highwater(int resetFlag){
return mx;
}
+#if 0
+/*
+** Return an estimate of the amount of unallocated memory.
+**
+** This the hard heap limit minus the current memory usage. It might
+** not be possible to allocate this much memory all at once. This is
+** only an estimate.
+*/
+sqlite3_int64 sqlite3EstMemoryAvailable(void){
+ sqlite3_int64 n;
+ sqlite3_mutex_enter(mem0.mutex);
+ n = mem0.alarmThreshold;
+ if( n<=0 ) n = mem0.hardLimit;
+ sqlite3_mutex_leave(mem0.mutex);
+ if( n<=0 ) n = LARGEST_INT64;
+ n -= sqlite3_memory_used();
+ if( n<0 ) n = 0;
+ return n;
+}
+#endif
+
/*
** Trigger the alarm
*/