Last active
October 12, 2015 15:21
-
-
Save chebizarro/f35a6afc4b1c3b43394b to your computer and use it in GitHub Desktop.
A simple test to show the memory leak from the Vala Compiler called via libvala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void parse (string[] args) { | |
Vala.Parser parser = new Vala.Parser (); | |
Vala.CodeContext context = new Vala.CodeContext(); | |
parser.parse (context); | |
Vala.CodeContext.push(context); | |
foreach (var path in args) | |
if (path.has_suffix (".vala") || path.has_suffix (".vapi") || path.has_suffix (".gs")) | |
context.add_source_file (new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, path)); | |
context.add_external_package("glib-2.0"); | |
context.add_external_package("gobject-2.0"); | |
context.add_external_package("libvala-0.30"); | |
foreach (var src in context.get_source_files ()) | |
parser.visit_source_file (src); | |
context.check (); | |
Vala.CodeContext.pop(); | |
} | |
/* the arguments are an array of full paths to valid Vala files */ | |
public static int main (string[] args) { | |
int i = 0; | |
while (i < 20) { | |
// simulate calling the compiler multiple times | |
parse(args); | |
i++; | |
} | |
return 0; | |
} |
Interesting results...
vala_code_visitor_ref//unref 80/100
vala_code_context_ref/unref 31920/31880
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to compile - valac libvalaleak.vala --pkg libvala-0.XX to run simply pass the full path of any number of vala files