Skip to content

Commit ed77cd5

Browse files
committed
Release pager page 1 memory and close pager after cevfs_build.
1 parent ff3944d commit ed77cd5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cevfs.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1862,6 +1862,7 @@ int cevfs_build(const char *srcDbPath, const char *destUri){
18621862
if( (rc = sqlite3_open_v2(destUri, &pDb, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, "cevfs-build"))==SQLITE_OK ){
18631863
sqlite3_vfs *pVfs = sqlite3_vfs_find("cevfs-build");
18641864
cevfs_info *pInfo = (cevfs_info *)pVfs->pAppData;
1865+
DbPage *pPage1 = NULL;
18651866
// import all pages
18661867
for(Pgno i=0; i<pageCount; i++){
18671868
// read source page
@@ -1871,12 +1872,19 @@ int cevfs_build(const char *srcDbPath, const char *destUri){
18711872
// write destination page
18721873
void *pData = sqlite3PagerGetData(pPage);
18731874
rc = cevfsWrite((sqlite3_file *)pInfo->pFile, pData, pageSize, pageSize*i);
1874-
if (i>1) sqlite3PagerUnref(pPage);
1875+
if (i==0) {
1876+
// To be deallocated later
1877+
pPage1 = pPage;
1878+
}else{
1879+
sqlite3PagerUnref(pPage);
1880+
}
18751881
if( rc != SQLITE_OK ) break;
18761882
}else{
18771883
break;
18781884
}
18791885
}
1886+
if (pPage1) sqlite3PagerUnref(pPage1);
1887+
sqlite3PagerClose(pPager);
18801888
rc = sqlite3_close(pDb);
18811889
}
18821890
}

0 commit comments

Comments
 (0)