2shady4u / godot-sqlite

GDExtension wrapper for SQLite (Godot 4.x+)
MIT License
850 stars 76 forks source link

Report to console when open_db() is opened twice #139

Closed Cryptoclysm closed 5 months ago

Cryptoclysm commented 1 year ago

Is your feature request related to a problem? Please describe. For the past few days I have been trying to track down a memory leak in my Godot server. Eventually, I found an open_db() without an accompanying close_db(). This was causing a leak of around 1MB every 10 seconds or so in my code, since the call happened fairly frequently.

Describe the solution you'd like When calling open_db() on an instance of gdsqlite where the db is already open, gdsqlite should:

  1. Throw an error/warning to the console
  2. Ignore the open_db command, since there is no reason that I know of to open_db() on an open database.

Describe alternatives you've considered Step 2 could be omitted, but that would open up the possibility of the developer leaking memory.

Additional context I am running a godot server on a Linux machine. There is complex SQLite usage over multiple DBs, and so I'm very conscious of avoiding errors and memory issues that may cause the server to misbehave long-term, which is how I caught issue 88. Thanks!

2shady4u commented 5 months ago

This request has now been implemented in f6e571eb9c6eb12193cccb1633ee09cf2ab9a306

2shady4u commented 5 months ago

This request is now part of the latest release!