mtangoo / wxDatabase

wxWidgets library for connecting to major relational database
http://mtangoo.github.io/database/index.html
36 stars 16 forks source link

Possible memory leak in MySQL sample? #13

Closed iwbnwif closed 8 years ago

iwbnwif commented 8 years ago

In the MySQL sample a new wxMysqlDatabase is instantiated at line 34, but isn't deleted.

This might be my understanding of the MySQL backend code, sorry for wasting time if so.

On the other hand if this is a bug, then perhaps it would be worth thinking about using some of the wxWidgets smart pointers here. Also for result sets because it would avoid having to close them each time, they would simply go out of focus and be deleted.

mtangoo commented 8 years ago

well, I put that sample quickly and so its a bug. I will have a look into it, but also PR is appreciated

iwbnwif commented 8 years ago

On the other hand if this is a bug, then perhaps it would be worth thinking about using some of the wxWidgets smart pointers here. Also for result sets because it would avoid having to close them each time, they would simply go out of focus and be deleted.

Thinking about this a bit more, for the examples it is probably unnecessary. Instead we can just declare the objects locally on the stack.

I still think a smart pointer (i.e. wxScopedPtr) typedef'd to something would be useful for things like transactions and possibly resultsets that can be passed around methods.

mtangoo commented 8 years ago

Thinking about this a bit more, for the examples it is probably unnecessary. Instead we can just declare the objects locally on the stack. Yeah that will be better, can you test that and make a PR? I currently work on adding ODBC support so I'm a bit tight (I work on "free time")

I still think a smart pointer (i.e. wxScopedPtr) typedef'd to something would be useful for things like transactions and possibly resultsets that can be passed around methods.

Can you open new Issue on specific things that you want me to add (eg transaction, explaining your solution)?

mtangoo commented 8 years ago

I will open until this bug is fixed (its simple .. but bug anyway ;))

iwbnwif commented 8 years ago

Sorry, closed by accident!

I will look into a concrete scheme for this while I am working on the Firebird backend, so it may take some time.

mtangoo commented 8 years ago

:+1: