diff options
author | drh <drh@noemail.net> | 2013-05-23 01:40:53 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-05-23 01:40:53 +0000 |
commit | 34e258c942f033d623bb559a0d7dbcd64246d30e (patch) | |
tree | 97fa8ed27cba32f79ffd822f9fe3879bfb10352e /src | |
parent | d399fb3de8c1a0b6e4bf995e22d07dce6218e22c (diff) | |
download | sqlite-34e258c942f033d623bb559a0d7dbcd64246d30e.tar.gz sqlite-34e258c942f033d623bb559a0d7dbcd64246d30e.zip |
Cause the mmap_size PRAGMA to immediately change the mmap space if the
database connection is already active. In particular, reducing mmap_size
will immediately free up process address space.
FossilOrigin-Name: 761177927cb51e4f5e66061ca39cf37edbe8346b
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 10 | ||||
-rw-r--r-- | src/os_win.c | 16 |
2 files changed, 20 insertions, 6 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index abc23a452..242c2a3c3 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3775,15 +3775,19 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ } case SQLITE_FCNTL_MMAP_SIZE: { i64 newLimit = *(i64*)pArg; + int rc = SQLITE_OK; if( newLimit>sqlite3GlobalConfig.mxMmap ){ newLimit = sqlite3GlobalConfig.mxMmap; } *(i64*)pArg = pFile->mmapSizeMax; - if( newLimit>=0 ){ + if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){ pFile->mmapSizeMax = newLimit; - if( newLimit<pFile->mmapSize ) pFile->mmapSize = newLimit; + if( pFile->mmapSize>0 ){ + unixUnmapfile(pFile); + rc = unixMapfile(pFile, -1); + } } - return SQLITE_OK; + return rc; } #ifdef SQLITE_DEBUG /* The pager calls this method to signal that it has done diff --git a/src/os_win.c b/src/os_win.c index aeb08814b..07b74cbe2 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -2816,6 +2816,9 @@ static void winModeBit(winFile *pFile, unsigned char mask, int *pArg){ /* Forward declaration */ static int getTempname(int nBuf, char *zBuf); +#if SQLITE_MAX_MMAP_SIZE>0 +static int winMapfile(winFile*, sqlite3_int64); +#endif /* ** Control and query of the open file handle. @@ -2899,13 +2902,20 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){ #if SQLITE_MAX_MMAP_SIZE>0 case SQLITE_FCNTL_MMAP_SIZE: { i64 newLimit = *(i64*)pArg; + int rc = SQLITE_OK; if( newLimit>sqlite3GlobalConfig.mxMmap ){ newLimit = sqlite3GlobalConfig.mxMmap; } *(i64*)pArg = pFile->mmapSizeMax; - if( newLimit>=0 ) pFile->mmapSizeMax = newLimit; - OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h)); - return SQLITE_OK; + if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){ + pFile->mmapSizeMax = newLimit; + if( pFile->mmapSize>0 ){ + (void)winUnmapfile(pFile); + rc = winMapfile(pFile, -1); + } + } + OSTRACE(("FCNTL file=%p, rc=%d\n", pFile->h, rc)); + return rc; } #endif } |