Fixed slow memory leak
authorSapan Bhatia <gwsapan@gmail.com>
Wed, 15 Dec 2010 22:13:21 +0000 (17:13 -0500)
committerSapan Bhatia <gwsapan@gmail.com>
Wed, 15 Dec 2010 22:13:21 +0000 (17:13 -0500)
directfifowatcher.ml
main.ml

index 8e8b4dc..206ca53 100644 (file)
@@ -162,7 +162,8 @@ let sigchld_handle s =
             try
               let fqp_in,fd_out = Hashtbl.find pidmap pid in
                 begin
-                  reopenentry fqp_in
+                  reopenentry fqp_in;
+                  Hashtbl.remove pidmap pid
                 end
             with _ -> ()
           end;
diff --git a/main.ml b/main.ml
index 43410ae..7f91dbf 100644 (file)
--- a/main.ml
+++ b/main.ml
@@ -25,6 +25,10 @@ let cmdspeclist =
     ("-failsafe",Arg.Set(Globals.failsafe), "Never crash. Be stupid, but never crash. Use at your own risk.");
   ]
 
+let sighup_handle s =
+  print "Received sighup. Running GC major pass";
+  Gc.major ()
+
 let _ =
   Arg.parse cmdspeclist (fun x->()) "Usage: vsys <list of mount points>";  
   Globals.logfd:=open_out_gen [Open_append;Open_creat] 0o644 !log_filepath;
@@ -55,6 +59,8 @@ let _ =
             input_file_list:=List.concat [!input_file_list;frontends]
         end;
 
+      Sys.set_signal Sys.sigusr1 (Sys.Signal_handle sighup_handle);
+
       let felst = List.map 
                     (fun lst->let (x,y)=lst in 
                        logprint "Slice %s (%s)\n" x y;