找到Vala / Sqlite3内存泄漏

时间:2015-11-09 16:11:38

标签: c sqlite valgrind vala

我的应用程序的一部分是一个守护程序,它在后台运行并定期收集数据并将其写入sqlite3数据库。 可悲的是,这个过程似乎每次“同步”(获取数据并将其写入数据库)都会泄漏一些内存。 我基本上做的是:创建一个整个同步过程发生的新线程,创建一些空的“Gee.LinkedList”,将它们传递给一些函数来填充它们,然后将它们传递给其他函数将它们写入db。在完成该过程后,我不知道对LinkedList的任何剩余引用。因此理论上应该释放数据。我在用完范围之前不久检查了对象的引用计数,它是1.我有办法检查对象是否已成功释放? 我尝试使用valgrind来查看我是否可以在代码中检测到问题。 Valgrind检测到大量“可能丢失”的内存,都指向我与sqlite3交互的函数。

==5038== 2,078,576 bytes in 1,594 blocks are possibly lost in loss record 4,283 of 4,283
==5038==    at 0x4C28C50: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==5038==    by 0x535E666: sqlite3MemMalloc (sqlite3.c:17913)
==5038==    by 0x533BC02: mallocWithAlarm (sqlite3.c:21581)
==5038==    by 0x533BC02: sqlite3Malloc (sqlite3.c:21612)
==5038==    by 0x533EA46: pcache1Alloc (sqlite3.c:41451)
==5038==    by 0x534534A: pcache1AllocPage (sqlite3.c:41545)
==5038==    by 0x534534A: pcache1FetchStage2 (sqlite3.c:41995)
==5038==    by 0x53712E4: sqlite3PcacheFetch (sqlite3.c:40697)
==5038==    by 0x53712E4: sqlite3PagerAcquire (sqlite3.c:48339)
==5038==    by 0x537806C: accessPayload (sqlite3.c:59076)
==5038==    by 0x537A1F7: vdbeMemFromBtreeResize (sqlite3.c:65928)
==5038==    by 0x53993F6: sqlite3VdbeExec (sqlite3.c:75460)
==5038==    by 0x539A83E: sqlite3Step (sqlite3.c:71540)
==5038==    by 0x539A83E: sqlite3_step (sqlite3.c:71601)
==5038==    by 0x420639: feed_reader_db_manager_update_articles (in /usr/bin/feedreader-daemon)
==5038==    by 0x44693B: feed_reader_feed_server_getArticles (in /usr/bin/feedreader-daemon)
==5038==    by 0x440B44: __lambda11_ (in /usr/bin/feedreader-daemon)
==5038==    by 0x440E46: ___lambda11__gthread_func (in /usr/bin/feedreader-daemon)
==5038==    by 0xAECE834: ??? (in /usr/lib64/libglib-2.0.so.0.4600.1)
==5038==    by 0xB861609: start_thread (in /usr/lib64/libpthread-2.22.so)
==5038==    by 0xB59BBBC: clone (in /usr/lib64/libc-2.22.so)

valgrind日志中提到的函数如下所示:

public void update_articles(Gee.LinkedList<article> articles)
{
    executeSQL("BEGIN TRANSACTION");

    var update_query = new QueryBuilder(QueryType.UPDATE, "main.articles");
    update_query.updateValuePair("unread", "$UNREAD");
    update_query.updateValuePair("marked", "$MARKED");
    update_query.updateValuePair("tags", "$TAGS");
    update_query.updateValuePair("lastModified", "$LASTMODIFIED");
    update_query.addEqualsCondition("articleID", "$ARTICLEID");
    update_query.build();

    Sqlite.Statement stmt;
    int ec = sqlite_db.prepare_v2 (update_query.get(), update_query.get().length, out stmt);

    if (ec != Sqlite.OK)
        logger.print(LogMessage.ERROR, "upate_articles: %s".printf(sqlite_db.errmsg()));

    int unread_position = stmt.bind_parameter_index("$UNREAD");
    int marked_position = stmt.bind_parameter_index("$MARKED");
    int tags_position = stmt.bind_parameter_index("$TAGS");
    int modified_position = stmt.bind_parameter_index("$LASTMODIFIED");
    int articleID_position = stmt.bind_parameter_index("$ARTICLEID");
    assert (unread_position > 0);
    assert (marked_position > 0);
    assert (tags_position > 0);
    assert (modified_position > 0);
    assert (articleID_position > 0);


    foreach(var article in articles)
    {
        stmt.bind_text(unread_position, article.getUnread().to_string());
        stmt.bind_text(marked_position, article.getMarked().to_string());
        stmt.bind_text(tags_position, article.getTagString());
        stmt.bind_int (modified_position, article.getLastModified());
        stmt.bind_text(articleID_position, article.getArticleID());

        while(stmt.step() != Sqlite.DONE) {}
        stmt.reset();
    }

    executeSQL("COMMIT TRANSACTION");
}

我还尝试检查生成的c代码是否有明显的错误,但没有成功。但也许我忽略了什么?它非常混乱:

void feed_reader_db_manager_update_articles (FeedReaderdbManager* self, GeeLinkedList* articles) {
FeedReaderQueryBuilder* update_query = NULL;
FeedReaderQueryBuilder* _tmp0_ = NULL;
FeedReaderQueryBuilder* _tmp1_ = NULL;
FeedReaderQueryBuilder* _tmp2_ = NULL;
FeedReaderQueryBuilder* _tmp3_ = NULL;
FeedReaderQueryBuilder* _tmp4_ = NULL;
FeedReaderQueryBuilder* _tmp5_ = NULL;
FeedReaderQueryBuilder* _tmp6_ = NULL;
gchar* _tmp7_ = NULL;
gchar* _tmp8_ = NULL;
sqlite3_stmt* stmt = NULL;
gint ec = 0;
sqlite3* _tmp9_ = NULL;
FeedReaderQueryBuilder* _tmp10_ = NULL;
gchar* _tmp11_ = NULL;
gchar* _tmp12_ = NULL;
FeedReaderQueryBuilder* _tmp13_ = NULL;
gchar* _tmp14_ = NULL;
gchar* _tmp15_ = NULL;
gint _tmp16_ = 0;
gint _tmp17_ = 0;
sqlite3_stmt* _tmp18_ = NULL;
gint _tmp19_ = 0;
gint _tmp20_ = 0;
gint _tmp21_ = 0;
gint unread_position = 0;
sqlite3_stmt* _tmp27_ = NULL;
gint _tmp28_ = 0;
gint marked_position = 0;
sqlite3_stmt* _tmp29_ = NULL;
gint _tmp30_ = 0;
gint tags_position = 0;
sqlite3_stmt* _tmp31_ = NULL;
gint _tmp32_ = 0;
gint modified_position = 0;
sqlite3_stmt* _tmp33_ = NULL;
gint _tmp34_ = 0;
gint articleID_position = 0;
sqlite3_stmt* _tmp35_ = NULL;
gint _tmp36_ = 0;
gint _tmp37_ = 0;
gint _tmp38_ = 0;
gint _tmp39_ = 0;
gint _tmp40_ = 0;
gint _tmp41_ = 0;
#line 651 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
g_return_if_fail (self != NULL);
#line 651 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
g_return_if_fail (articles != NULL);
#line 653 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
feed_reader_db_manager_executeSQL (self, "BEGIN TRANSACTION");
#line 655 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp0_ = feed_reader_query_builder_new (FEED_READER_QUERY_TYPE_UPDATE, "main.articles");
#line 655 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
update_query = _tmp0_;
#line 656 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp1_ = update_query;
#line 656 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
feed_reader_query_builder_updateValuePair (_tmp1_, "unread", "$UNREAD");
#line 657 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp2_ = update_query;
#line 657 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
feed_reader_query_builder_updateValuePair (_tmp2_, "marked", "$MARKED");
#line 658 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp3_ = update_query;
#line 658 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
feed_reader_query_builder_updateValuePair (_tmp3_, "tags", "$TAGS");
#line 659 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp4_ = update_query;
#line 659 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
feed_reader_query_builder_updateValuePair (_tmp4_, "lastModified", "$LASTMODIFIED");
#line 660 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp5_ = update_query;
#line 660 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
feed_reader_query_builder_addEqualsCondition (_tmp5_, "articleID", "$ARTICLEID", TRUE, FALSE);
#line 661 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp6_ = update_query;
#line 661 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp7_ = feed_reader_query_builder_build (_tmp6_);
#line 661 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp8_ = _tmp7_;
#line 661 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_g_free0 (_tmp8_);
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp9_ = self->priv->sqlite_db;
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp10_ = update_query;
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp11_ = feed_reader_query_builder_get (_tmp10_);
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp12_ = _tmp11_;
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp13_ = update_query;
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp14_ = feed_reader_query_builder_get (_tmp13_);
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp15_ = _tmp14_;
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp16_ = strlen (_tmp15_);
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp17_ = _tmp16_;
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp19_ = sqlite3_prepare_v2 (_tmp9_, _tmp12_, _tmp17_, &_tmp18_, NULL);
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_sqlite3_finalize0 (stmt);
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
stmt = _tmp18_;
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp20_ = _tmp19_;
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_g_free0 (_tmp15_);
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_g_free0 (_tmp12_);
#line 664 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
ec = _tmp20_;
#line 666 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp21_ = ec;
#line 666 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
if (_tmp21_ != SQLITE_OK) {
#line 5122 "DB_Manager.c"
    FeedReaderLogger* _tmp22_ = NULL;
    sqlite3* _tmp23_ = NULL;
    const gchar* _tmp24_ = NULL;
    gchar* _tmp25_ = NULL;
    gchar* _tmp26_ = NULL;
#line 667 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _tmp22_ = feed_reader_logger;
#line 667 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _tmp23_ = self->priv->sqlite_db;
#line 667 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _tmp24_ = sqlite3_errmsg (_tmp23_);
#line 667 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _tmp25_ = g_strdup_printf ("upate_articles: %s", _tmp24_);
#line 667 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _tmp26_ = _tmp25_;
#line 667 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    feed_reader_logger_print (_tmp22_, FEED_READER_LOG_MESSAGE_ERROR, _tmp26_);
#line 667 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _g_free0 (_tmp26_);
#line 5142 "DB_Manager.c"
}
#line 669 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp27_ = stmt;
#line 669 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp28_ = sqlite3_bind_parameter_index (_tmp27_, "$UNREAD");
#line 669 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
unread_position = _tmp28_;
#line 670 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp29_ = stmt;
#line 670 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp30_ = sqlite3_bind_parameter_index (_tmp29_, "$MARKED");
#line 670 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
marked_position = _tmp30_;
#line 671 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp31_ = stmt;
#line 671 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp32_ = sqlite3_bind_parameter_index (_tmp31_, "$TAGS");
#line 671 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
tags_position = _tmp32_;
#line 672 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp33_ = stmt;
#line 672 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp34_ = sqlite3_bind_parameter_index (_tmp33_, "$LASTMODIFIED");
#line 672 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
modified_position = _tmp34_;
#line 673 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp35_ = stmt;
#line 673 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp36_ = sqlite3_bind_parameter_index (_tmp35_, "$ARTICLEID");
#line 673 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
articleID_position = _tmp36_;
#line 674 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp37_ = unread_position;
#line 674 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_vala_assert (_tmp37_ > 0, "unread_position > 0");
#line 675 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp38_ = marked_position;
#line 675 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_vala_assert (_tmp38_ > 0, "marked_position > 0");
#line 676 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp39_ = tags_position;
#line 676 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_vala_assert (_tmp39_ > 0, "tags_position > 0");
#line 677 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp40_ = modified_position;
#line 677 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_vala_assert (_tmp40_ > 0, "modified_position > 0");
#line 678 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_tmp41_ = articleID_position;
#line 678 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_vala_assert (_tmp41_ > 0, "articleID_position > 0");
#line 5194 "DB_Manager.c"
{
    GeeLinkedList* _article_list = NULL;
    GeeLinkedList* _tmp42_ = NULL;
    GeeLinkedList* _tmp43_ = NULL;
    gint _article_size = 0;
    GeeLinkedList* _tmp44_ = NULL;
    gint _tmp45_ = 0;
    gint _tmp46_ = 0;
    gint _article_index = 0;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _tmp42_ = articles;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _tmp43_ = _g_object_ref0 (_tmp42_);
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _article_list = _tmp43_;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _tmp44_ = _article_list;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _tmp45_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp44_);
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _tmp46_ = _tmp45_;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _article_size = _tmp46_;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _article_index = -1;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    while (TRUE) {
#line 5222 "DB_Manager.c"
        gint _tmp47_ = 0;
        gint _tmp48_ = 0;
        gint _tmp49_ = 0;
        FeedReaderarticle* article = NULL;
        GeeLinkedList* _tmp50_ = NULL;
        gint _tmp51_ = 0;
        gpointer _tmp52_ = NULL;
        sqlite3_stmt* _tmp53_ = NULL;
        gint _tmp54_ = 0;
        FeedReaderarticle* _tmp55_ = NULL;
        FeedReaderArticleStatus _tmp56_ = 0;
        gchar* _tmp57_ = NULL;
        GDestroyNotify _tmp58_ = NULL;
        sqlite3_stmt* _tmp59_ = NULL;
        gint _tmp60_ = 0;
        FeedReaderarticle* _tmp61_ = NULL;
        FeedReaderArticleStatus _tmp62_ = 0;
        gchar* _tmp63_ = NULL;
        GDestroyNotify _tmp64_ = NULL;
        sqlite3_stmt* _tmp65_ = NULL;
        gint _tmp66_ = 0;
        FeedReaderarticle* _tmp67_ = NULL;
        gchar* _tmp68_ = NULL;
        GDestroyNotify _tmp69_ = NULL;
        sqlite3_stmt* _tmp70_ = NULL;
        gint _tmp71_ = 0;
        FeedReaderarticle* _tmp72_ = NULL;
        gint _tmp73_ = 0;
        sqlite3_stmt* _tmp74_ = NULL;
        gint _tmp75_ = 0;
        FeedReaderarticle* _tmp76_ = NULL;
        gchar* _tmp77_ = NULL;
        GDestroyNotify _tmp78_ = NULL;
        sqlite3_stmt* _tmp81_ = NULL;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp47_ = _article_index;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _article_index = _tmp47_ + 1;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp48_ = _article_index;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp49_ = _article_size;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        if (!(_tmp48_ < _tmp49_)) {
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
            break;
#line 5269 "DB_Manager.c"
        }
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp50_ = _article_list;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp51_ = _article_index;
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp52_ = gee_abstract_list_get ((GeeAbstractList*) _tmp50_, _tmp51_);
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        article = (FeedReaderarticle*) _tmp52_;
#line 683 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp53_ = stmt;
#line 683 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp54_ = unread_position;
#line 683 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp55_ = article;
#line 683 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp56_ = feed_reader_article_getUnread (_tmp55_);
#line 683 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp57_ = feed_reader_article_status_to_string (_tmp56_);
#line 683 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp58_ = g_free;
#line 683 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        sqlite3_bind_text (_tmp53_, _tmp54_, _tmp57_, -1, _tmp58_);
#line 684 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp59_ = stmt;
#line 684 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp60_ = marked_position;
#line 684 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp61_ = article;
#line 684 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp62_ = feed_reader_article_getMarked (_tmp61_);
#line 684 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp63_ = feed_reader_article_status_to_string (_tmp62_);
#line 684 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp64_ = g_free;
#line 684 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        sqlite3_bind_text (_tmp59_, _tmp60_, _tmp63_, -1, _tmp64_);
#line 685 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp65_ = stmt;
#line 685 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp66_ = tags_position;
#line 685 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp67_ = article;
#line 685 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp68_ = feed_reader_article_getTagString (_tmp67_);
#line 685 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp69_ = g_free;
#line 685 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        sqlite3_bind_text (_tmp65_, _tmp66_, _tmp68_, -1, _tmp69_);
#line 686 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp70_ = stmt;
#line 686 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp71_ = modified_position;
#line 686 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp72_ = article;
#line 686 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp73_ = feed_reader_article_getLastModified (_tmp72_);
#line 686 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        sqlite3_bind_int (_tmp70_, _tmp71_, _tmp73_);
#line 687 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp74_ = stmt;
#line 687 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp75_ = articleID_position;
#line 687 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp76_ = article;
#line 687 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp77_ = feed_reader_article_getArticleID (_tmp76_);
#line 687 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp78_ = g_free;
#line 687 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        sqlite3_bind_text (_tmp74_, _tmp75_, _tmp77_, -1, _tmp78_);
#line 689 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        while (TRUE) {
#line 5343 "DB_Manager.c"
            sqlite3_stmt* _tmp79_ = NULL;
            gint _tmp80_ = 0;
#line 689 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
            _tmp79_ = stmt;
#line 689 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
            _tmp80_ = sqlite3_step (_tmp79_);
#line 689 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
            if (!(_tmp80_ != SQLITE_DONE)) {
#line 689 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
                break;
#line 5354 "DB_Manager.c"
            }
        }
#line 690 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _tmp81_ = stmt;
#line 690 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        sqlite3_reset (_tmp81_);
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
        _g_object_unref0 (article);
#line 5363 "DB_Manager.c"
    }
#line 681 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
    _g_object_unref0 (_article_list);
#line 5367 "DB_Manager.c"
}
#line 693 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
feed_reader_db_manager_executeSQL (self, "COMMIT TRANSACTION");
#line 651 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_sqlite3_finalize0 (stmt);
#line 651 "/home/jeanluc/Projects/FeedReader/master/src/DB_Manager.vala"
_g_object_unref0 (update_query);
#line 5375 "DB_Manager.c"
}

非常感谢任何类型的提示我如何追踪这个问题:)

1 个答案:

答案 0 :(得分:2)

为什么你认为你有内存泄漏?

如果Vala引用计数对象在超出范围之前的计数为1,我相信它将被unref释放。在Vala方面,您应该知道GLib可以通过使用自己的堆调用来混淆Valgrind - 请参阅Valgrind reports memory 'possibly lost' when using glib data types。我认为Valgrind在某个地方有一个抑制文件。

看起来你在问题中粘贴的Valgrind报告就是说SQLite在step之后没有释放它的内存。这可能是Is there any memory leak in the normal routine of sqlite3_*()?

中建议的缓存事项

我很好奇为什么Vala行号在Valgrind中没有显示,因为你为C输出设置了--debug标志。