Skip to content

Commit 6a31cc2

Browse files
Anthony Leonardo GracioAnthonyLeonardoGracio
authored andcommitted
V624-007: Fix memory leak on server finalization
1 parent 0bee292 commit 6a31cc2

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

source/ada/lsp-ada_driver.adb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ begin
348348
end;
349349
end if;
350350

351+
Ada_Handler.Stop_File_Monitoring;
351352
Server.Finalize;
352353
if Clean_ALS_Dir then
353354
Ada_Handler.Clean_Logs (ALS_Dir);

source/ada/lsp-ada_handlers.adb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,17 +507,24 @@ package body LSP.Ada_Handlers is
507507
Self.Total_Files_Indexed := 0;
508508
end Release_Contexts_And_Project_Info;
509509

510+
--------------------------
511+
-- Stop_File_Monitoring --
512+
--------------------------
513+
514+
procedure Stop_File_Monitoring (Self : access Message_Handler) is
515+
begin
516+
if Self.File_Monitor.Assigned then
517+
Self.File_Monitor.Stop_Monitoring_Directories;
518+
end if;
519+
end Stop_File_Monitoring;
520+
510521
-------------
511522
-- Cleanup --
512523
-------------
513524

514525
procedure Cleanup (Self : access Message_Handler)
515526
is
516527
begin
517-
if Self.File_Monitor.Assigned then
518-
Self.File_Monitor.Stop_Monitoring_Directories;
519-
end if;
520-
521528
-- Cleanup documents
522529
for Document of Self.Open_Documents loop
523530
Free (Document);

source/ada/lsp-ada_handlers.ads

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ package LSP.Ada_Handlers is
6161
-- This procedure will be called when an unexpected error is raised in the
6262
-- request processing loop.
6363

64+
procedure Stop_File_Monitoring (Self : access Message_Handler);
65+
6466
procedure Cleanup (Self : access Message_Handler);
6567
-- Free memory referenced by Self
6668

0 commit comments

Comments
 (0)