[Vala] using Variant: memory leaks
- From: Luca Dionisi <luca dionisi gmail com>
- To: vala-list <vala-list gnome org>
- Subject: [Vala] using Variant: memory leaks
- Date: Fri, 16 Dec 2011 15:23:49 +0100
Hi folks
I am using Vala 0.12
This simple function leaks memory
void leaks()
{
Variant v = "hello";
string s = (string)v;
}
Valgrind reveals it:
==17176== LEAK SUMMARY:
==17176== definitely lost: 6 bytes in 1 blocks
And if you run it in a loop it will eat forever.
I don't know if it is a known bug, if it is fixed in more current
valac, and so on.
Just going more in details, could this help, I will say that the
problem is that that form of casting a Variant to a string will
produce a call to g_variant_dup_string and then the assignment will
produce a call to g_strdup.
Instead, the following form of retrieving a Variant works fine:
void withget()
{
Variant v = "hello";
string s;
v.get("s", out s);
}
HTH,
--Luca
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]