Thanks for your answer. Simon Why are you trying to do memory-mapping on a 
portable device ? Is it for speed ? Do you absolutely need it ? Yes. even on 
iDevice, [mmap] can get faster than sequential I/O. Sometimes it will be twice 
faster. Simon Won't the standard SQLite API do the job well enough ? I did use 
the standard SQLite API. It maps the whole db file into address space. When the 
db file is too big, the [mmap] will failed and turn back to sequential I/O 
method. I have another way to solve this problem. The address space might 
be“scttered”. There is not enough space to fit a BIG file. But there are a lot 
of fragment space to fit multiple small regions. So I can map multiple regions 
of file, instead of mapping the whole db file. For example, mapping 256 
4MB-regions, instead of mapping the whole 1GB file. This solution should modify 
the [unixRemapFile] method in the source code of SQLite, also, I should remap 
the exact region into the pMapRegion variable. In my testcase, I can only 
[mmap] a db file at most 1.4GB size. But in this new way, I can map a file at 
most 3.2GB. The test device is iPhone 6S.




原始邮件
发件人:sanhua.zhsanhua...@foxmail.com
收件人:SQLite mailing listsqlite-us...@mailinglists.sqlite.org
发送时间:2016年8月31日(周三) 16:39
主题:Re: [sqlite] Why MMAP return ENOMEM in SQLite?


Thanks for your answer. Simon Why are you trying to do memory-mapping on a 
portable device ? Is it for speed ? Do you absolutely need it ? Yes. even on 
iDevice, [mmap] can get faster than sequential I/O. Sometime it will be twice 
faster. Simon Won't the standard SQLite API do the job well enough ? I did use 
the standard SQLite API. It maps the whole db file into address space. When the 
db file is too big, the [mmap] will failed and back tosequential I/O method. I 
have another way to solve this problem. The address space might be“scttered”. 
There is not enough space to fit a BIG file. But there are a lot of fragment 
space to fit multiple small region. So I can map multiple regions of file, 
instead of mapping the whole db file. For example, mapping 128 4MB-regions, 
instead of mapping the whole 1GB file. This solution should modify the 
[unixRemapFile] method in the source code of SQLite, also, I should remap the 
exact region into the pMapRegion variable. In my testcase, I can only [mmap] a 
db file at most 1.4GB size. But in this new way, I can map a file at most 
3.2GB. The test device is iPhone 6S. 原始邮件 发件人:Simon slavinslav...@bigfraud.org 
收件人:SQLite mailing listsqlite-us...@mailinglists.sqlite.org 发送时间:2016年8月31日(周三) 
14:38 主题:Re: [sqlite] Why MMAP return ENOMEM in SQLite? On 31 Aug 2016, at 
4:40am, sanhua.zh sanhua...@foxmail.com wrote: Is it caused by mmap file too 
big that the address space is not enough? Yes. Under iOS, memory maps can only 
be as big as the available physical memory. You're working on a tiny 
multi-tasking device and memory is at a premium. You can't afford to hog 
memory. Nor can you do data-handling so fast that it runs down the battery or 
overheats the device. Also, iDevices before the iPhone 5S in 2013 ran a 32-bit 
version of iOS, limiting them to 4GB of memory per App. If yes, then how can I 
get the allowed mmap file size? This figure would be useless since available 
physical memory varies depending on things your application cannot prevent. For 
instance, you may find out how much free memory there is, but then there may be 
in incoming phonecall. iOS will then allocate some of that memory to the 
process dealing with the phonecall. And, of course you cannot do anything to 
interfere with a phonecall because that is more important than an App. Why are 
you trying to do memory-mapping on a portable device ? Is it for speed ? Do you 
absolutely need it ? Won't the standard SQLite API do the job well enough ? 
Simon. _______________________________________________ sqlite-users mailing 
list sqlite-users@mailinglists.sqlite.org 
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users 
_______________________________________________ sqlite-users mailing list 
sqlite-users@mailinglists.sqlite.org 
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to