- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我的应用程序的一部分是一个在后台运行并定期收集数据并将其写入 sqlite3 数据库的守护进程。可悲的是,这个过程似乎在每次“同步”(获取数据并将其写入数据库)时都会泄漏一些内存。我基本上做的是:在整个同步过程发生的地方创建一个新线程,创建一些空的“Gee.LinkedList”,将它们传递给一些函数来填充它们,然后将它们传递给其他函数以将它们写入数据库。在该过程完成后,我不知道对 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"
}
非常感谢任何类型的提示我如何追踪这个问题:)
最佳答案
为什么你认为你有内存泄漏?
如果 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
标志。
关于c - 定位Vala/Sqlite3内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33613357/
#include using namespace std; class C{ private: int value; public: C(){ value = 0;
这个问题已经有答案了: What is the difference between char a[] = ?string?; and char *p = ?string?;? (8 个回答) 已关闭
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 7 年前。 此帖子已于 8 个月
除了调试之外,是否有任何针对 c、c++ 或 c# 的测试工具,其工作原理类似于将独立函数复制粘贴到某个文本框,然后在其他文本框中输入参数? 最佳答案 也许您会考虑单元测试。我推荐你谷歌测试和谷歌模拟
我想在第二台显示器中移动一个窗口 (HWND)。问题是我尝试了很多方法,例如将分辨率加倍或输入负值,但它永远无法将窗口放在我的第二台显示器上。 关于如何在 C/C++/c# 中执行此操作的任何线索 最
我正在寻找 C/C++/C## 中不同类型 DES 的现有实现。我的运行平台是Windows XP/Vista/7。 我正在尝试编写一个 C# 程序,它将使用 DES 算法进行加密和解密。我需要一些实
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
有没有办法强制将另一个 窗口置于顶部? 不是应用程序的窗口,而是另一个已经在系统上运行的窗口。 (Windows, C/C++/C#) 最佳答案 SetWindowPos(that_window_ha
假设您可以在 C/C++ 或 Csharp 之间做出选择,并且您打算在 Windows 和 Linux 服务器上运行同一服务器的多个实例,那么构建套接字服务器应用程序的最明智选择是什么? 最佳答案 如
你们能告诉我它们之间的区别吗? 顺便问一下,有什么叫C++库或C库的吗? 最佳答案 C++ 标准库 和 C 标准库 是 C++ 和 C 标准定义的库,提供给 C++ 和 C 程序使用。那是那些词的共同
下面的测试代码,我将输出信息放在注释中。我使用的是 gcc 4.8.5 和 Centos 7.2。 #include #include class C { public:
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我的客户将使用名为 annoucement 的结构/类与客户通信。我想我会用 C++ 编写服务器。会有很多不同的类继承annoucement。我的问题是通过网络将这些类发送给客户端 我想也许我应该使用
我在 C# 中有以下函数: public Matrix ConcatDescriptors(IList> descriptors) { int cols = descriptors[0].Co
我有一个项目要编写一个函数来对某些数据执行某些操作。我可以用 C/C++ 编写代码,但我不想与雇主共享该函数的代码。相反,我只想让他有权在他自己的代码中调用该函数。是否可以?我想到了这两种方法 - 在
我使用的是编写糟糕的第 3 方 (C/C++) Api。我从托管代码(C++/CLI)中使用它。有时会出现“访问冲突错误”。这使整个应用程序崩溃。我知道我无法处理这些错误[如果指针访问非法内存位置等,
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我有一些 C 代码,将使用 P/Invoke 从 C# 调用。我正在尝试为这个 C 函数定义一个 C# 等效项。 SomeData* DoSomething(); struct SomeData {
这个问题已经有答案了: Why are these constructs using pre and post-increment undefined behavior? (14 个回答) 已关闭 6
我是一名优秀的程序员,十分优秀!