memory lead while using Glib regexp
- From: "Xi Yang" <jiandingzhe 163 com>
- To: "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: memory lead while using Glib regexp
- Date: Fri, 2 Mar 2012 11:00:46 +0800 (CST)
Hi, everyone!
I use Glib's regular expression in a cycle, and find a rapid memory consumption increase. Did I forget to
release anything?
Thanks a lot!
================= code below ======================
GRegex* regex_illumina = g_regex_new(
"@(.+):(\\d+):(\\d+):(\\d+):(\\d+)#(\\d+)/([12])",
G_REGEX_OPTIMIZE,
GRegexMatchFlags(0),
NULL
);
GRegex* regex_casava_1p8 = g_regex_new(
"@(.+):(.+):(.+):(\\d+):(\\d+):(\\d+):(\\d+) ([12]):([YN]):\\d+:(\\w*)",
G_REGEX_OPTIMIZE,
GRegexMatchFlags(0),
NULL
);
// inside cycle body
gchar* tile_str;
int tile;
GMatchInfo* what;
// match and fetch something
if ( g_regex_match(regex_illumina, seq.header.c_str(), GRegexMatchFlags(0), &what) ) {
tile_str = g_match_info_fetch(what,3);
}
else if ( g_regex_match(regex_casava_1p8, seq.header.c_str(), GRegexMatchFlags(0), &what) ) {
tile_str = g_match_info_fetch(what,5);
}
else {
throw runtime_error("failed to parse header line:\n"+seq.header);
}
// parse a number
if (sscanf(tile_str,"%d",&tile)!=1)
throw runtime_error("failed to fetch tile from "+seq.header);
// release match info and fetched string
g_match_info_free(what);
g_free(tile_str);
// end of cycle body
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]