On Mon, Oct 15, 2012 at 4:15 PM, Petr Kovalev <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
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>


-- 
D. Richard Hipp
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