- 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/
我在具有 2CPU 和 3.75GB 内存 (https://aws.amazon.com/ec2/instance-types/) 的 c3.large Amazon EC2 ubuntu 机器上运
我想通过用户空间中的mmap-ing并将地址发送到内核空间从用户空间写入VGA内存(视频内存,而不是缓冲区),我将使用pfn remap将这些mmap-ed地址映射到vga内存(我将通过 lspci
在 Mathematica 中,如果你想让一个函数记住它的值,它在语法上是很轻松的。例如,这是标准示例 - 斐波那契: fib[1] = 1 fib[2] = 1 fib[n_]:= fib[n] =
我读到动态内存是在运行时在堆上分配的,而静态内存是在编译时在堆栈上分配的,因为编译器知道在编译时必须分配多少内存。 考虑以下代码: int n; cin>>n; int a[n]; 如果仅在运行期间读
我是 Python 的新手,但我之前还不知道这一点。我在 for 循环中有一个基本程序,它从站点请求数据并将其保存到文本文件但是当我检查我的任务管理器时,我发现内存使用量只增加了?长时间运行时,这对我
我正在设计一组数学函数并在 CPU 和 GPU(使用 CUDA)版本中实现它们。 其中一些函数基于查找表。大多数表占用 4KB,其中一些占用更多。基于查找表的函数接受一个输入,选择查找表的一两个条目,
读入一个文件,内存被动态分配给一个字符串,文件内容将被放置在这里。这是在函数内部完成的,字符串作为 char **str 传递。 使用 gdb 我发现在行 **(str+i) = fgetc(aFil
我需要证实一个理论。我正在学习 JSP/Java。 在查看了一个现有的应用程序(我没有写)之后,我注意到一些我认为导致我们的性能问题的东西。或者至少是其中的一部分。 它是这样工作的: 1)用户打开搜索
n我想使用memoization缓存某些昂贵操作的结果,这样就不会一遍又一遍地计算它们。 两个memoise和 R.cache适合我的需要。但是,我发现缓存在调用之间并不可靠。 这是一个演示我看到的问
我目前正在分析一些 javascript shell 代码。这是该脚本中的一行: function having() { memory = memory; setTimeout("F0
我有一种情况,我想一次查询数据库,然后再将整个数据缓存在内存中。 我得到了内存中 Elasticsearch 的建议,我用谷歌搜索了它是什么,以及如何在自己的 spring boot 应用程序中实现它
我正在研究 Project Euler (http://projecteuler.net/problem=14) 的第 14 题。我正在尝试使用内存功能,以便将给定数字的序列长度保存为部分结果。我正在
所以,我一直在做 Java 内存/注意力游戏作业。我还没有达到我想要的程度,它只完成了一半,但我确实让 GUI 大部分工作了......直到我尝试向我的框架添加单选按钮。我认为问题可能是因为我将 JF
我一直在尝试使用 Flask-Cache 的 memoize 功能来仅返回 statusTS() 的缓存结果,除非在另一个请求中满足特定条件,然后删除缓存。 但它并没有被删除,并且 Jinja 模板仍
我对如何使用 & 运算符来减少内存感到非常困惑。 我可以回答下面的问题吗? clase C{ function B(&$a){ $this->a = &$a; $thi
在编写代码时,我遇到了一个有趣的问题。 我有一个 PersonPOJO,其 name 作为其 String 成员之一及其 getter 和 setter class PersonPOJO { priv
在此代码中 public class Base { int length, breadth, height; Base(int l, int b, int h) { l
Definition Structure padding is the process of aligning data members of the structure in accordance
在 JavaScript Ninja 的 secret 中,作者提出了以下方案,用于在没有闭包的情况下内存函数结果。他们通过利用函数是对象这一事实并在函数上定义一个属性来存储过去调用函数的结果来实现这
我正在尝试找出 map 消耗的 RAM 量。所以,我做了以下事情;- Map cr = crPair.collectAsMap(); // 200+ entries System.out.printl
我是一名优秀的程序员,十分优秀!