Hello Richard,

Thank You for the answer.
We think it would make sense to reflect this rule for zeroblobs in the 
documentation,
so other teams would save time not spending it when trying to fix bugs that 
don't really exist.
Probably, we just missed this mentioning in the documentation, so if we did, 
please point us to this.
Anyway, thanks a lot.

Dmitry Tsinin
OS33

From: drhsql...@gmail.com [mailto:drhsql...@gmail.com] On Behalf Of Richard Hipp
Sent: Tuesday, October 16, 2012 4:24 PM
To: General Discussion of SQLite Database
Cc: Dmitry Tsinin; Dennis Davydov; Alex Osipov; Alexander Anikin
Subject: Re: [sqlite] Zeroblob initialization memory allocation issue


On Mon, Oct 15, 2012 at 4:15 PM, Petr Kovalev 
<pkova...@os33.com<mailto:pkova...@os33.com>> wrote:
Hello worldwide Sqlite team!

We've found an issue caused by zeroblob initialization. Depending on the table 
columns creation order, zeroblob initialization causes huge memory allocation 
or not.

Attached sample project is for Mono, but we've tried the same scenario with 
native methods. In first case no additional memory is allocated, but in 
ZeroblobFail method approx 100Mb of memory is allocated for a quick period of 
zeroblob creation.

Could you please help to explain the behavior and provide possible workarounds?

Here is quote:
http://www.sqlite.org/c3ref/bind_blob.html
<The sqlite3_bind_zeroblob() routine binds a BLOB of length N that is filled 
with zeroes. A zeroblob uses a fixed amount of memory (just an integer to hold 
its size) while it is being processed. Zeroblobs are intended to serve as 
placeholders for BLOBs whose content is later written using incremental BLOB 
I/O<http://www.sqlite.org/c3ref/blob_open.html> routines>

In order for zeroblobs to work as above (using a fixed amount of memory no 
matter how big they are) all zeroblobs must be at the end of the row.  In other 
words, the columns of the table that are receiving the zeroblobs must be the 
last columns in the table.  If any non-zero content follows the zeroblob, then 
the zeroblob is expanded into a literal sequence of zero bytes, meaning memory 
must be allocated for the entire zeroblob.



Any advice would be great.

Thanks.

Petr.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org<mailto:sqlite-users@sqlite.org>
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



--
D. Richard Hipp
d...@sqlite.org<mailto:d...@sqlite.org>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to