[gnome-db] Memory usage
- From: David Régade <dregade viewsurf com>
- To: gnome-db-list gnome org
- Subject: [gnome-db] Memory usage
- Date: Fri, 18 Jan 2013 09:44:28 +0100
Hi,
I try to use gda to connect to a mysql database. I used SimpleExample found in
samples directory and changed dsn to match my needs.
This is only a connect/disconnect loop.
Here is the code:
#include <glib-object.h>
#include <glib/gprintf.h>
#include <libgda/libgda.h>
#include <sql-parser/gda-sql-parser.h>
#include <unistd.h>
GdaConnection *open_connection( void );
int main( int argc, char *argv[] ) {
int i = 0;
gda_init( );
GdaConnection *cnc;
for(i = 0; i<atoi(argv[1]); i++) {
cnc = open_connection( );
gda_connection_close( cnc );
g_object_unref( cnc );
}
return 0;
}
/*
* Open a connection to the example.db file
*/
GdaConnection *open_connection( ) {
GdaConnection *cnc;
GError *error = NULL;
GdaSqlParser *parser;
/* open connection */
cnc = gda_connection_open_from_string( "MySQL", "DB_NAME=viewbox",
"USERNAME=user;PASSWORD=pass",GDA_CONNECTION_OPTIONS_READ_ONLY,
&error );
if( !cnc ) {
g_print( "Could not open connection database: %s\n",
error && error->message ? error->message : "No detail" );
exit( 1 );
}
/* create an SQL parser */
parser = gda_connection_create_parser( cnc );
if( !parser ) /* @cnc doe snot provide its own parser => use default one */
parser = gda_sql_parser_new( );
/* attach the parser object to the connection */
g_object_set_data_full( G_OBJECT( cnc ), "parser", parser, g_object_unref );
return cnc;
}
There is no problem with sqlite but memory usage with mysql provider always
increase (thanks to valgrind).
Is there any problem wth this piece of code ?
Regards
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]