Fossil SCM

A better way to keep the size of the content cache under control.

drh 2011-05-13 13:42 trunk
Commit 6a714fc03647163d88601c9c86ebccbde0a61285
1 file changed +3 -2
+3 -2
--- src/content.c
+++ src/content.c
@@ -79,14 +79,15 @@
7979
** The cache will deallocate memory when it has finished with it.
8080
*/
8181
void content_cache_insert(int rid, Blob *pBlob){
8282
struct cacheLine *p;
8383
if( contentCache.n>500 || contentCache.szTotal>50000000 ){
84
- int cnt = 0;
84
+ i64 szBefore;
8585
do{
86
+ szBefore = contentCache.szTotal;
8687
content_cache_expire_oldest();
87
- }while( cnt++<10 && contentCache.szTotal>50000000 );
88
+ }while( contentCache.szTotal>50000000 && contentCache.szTotal<szBefore );
8889
}
8990
if( contentCache.n>=contentCache.nAlloc ){
9091
contentCache.nAlloc = contentCache.nAlloc*2 + 10;
9192
contentCache.a = fossil_realloc(contentCache.a,
9293
contentCache.nAlloc*sizeof(contentCache.a[0]));
9394
--- src/content.c
+++ src/content.c
@@ -79,14 +79,15 @@
79 ** The cache will deallocate memory when it has finished with it.
80 */
81 void content_cache_insert(int rid, Blob *pBlob){
82 struct cacheLine *p;
83 if( contentCache.n>500 || contentCache.szTotal>50000000 ){
84 int cnt = 0;
85 do{
 
86 content_cache_expire_oldest();
87 }while( cnt++<10 && contentCache.szTotal>50000000 );
88 }
89 if( contentCache.n>=contentCache.nAlloc ){
90 contentCache.nAlloc = contentCache.nAlloc*2 + 10;
91 contentCache.a = fossil_realloc(contentCache.a,
92 contentCache.nAlloc*sizeof(contentCache.a[0]));
93
--- src/content.c
+++ src/content.c
@@ -79,14 +79,15 @@
79 ** The cache will deallocate memory when it has finished with it.
80 */
81 void content_cache_insert(int rid, Blob *pBlob){
82 struct cacheLine *p;
83 if( contentCache.n>500 || contentCache.szTotal>50000000 ){
84 i64 szBefore;
85 do{
86 szBefore = contentCache.szTotal;
87 content_cache_expire_oldest();
88 }while( contentCache.szTotal>50000000 && contentCache.szTotal<szBefore );
89 }
90 if( contentCache.n>=contentCache.nAlloc ){
91 contentCache.nAlloc = contentCache.nAlloc*2 + 10;
92 contentCache.a = fossil_realloc(contentCache.a,
93 contentCache.nAlloc*sizeof(contentCache.a[0]));
94

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button