← Back to Challenges / Challenge #1

Memory Leak in Database Connection

★★★☆☆
📁 facebook/react 🔢 abc1234 Memory Safety
★★★☆☆
Difficulty
+100 XP reward
file.js
1 class DatabaseConnector {
2 constructor(url) {
3 this.url = url;
4 this.connection = null;
5 }
6
7 connect() {
8 this.connection = createConnection(this.url);
9 }
10
11 query(sql) {
12 return this.connection.execute(sql);
13 }
14
15 disconnect() {
16 // Memory leak: connection never closed
17 }
18 }

Submit Your Fix

Lines marked: 0

Click a marked line number below to edit its fix.

Click on lines in the diff above to mark them, then add your fixes here.