2017-07-17 83 views
1

单个页面Websharper应用程序中的示例代码展示了我的项目中遇到的问题。Websharper应用程序性能下降,可能的内存泄漏

随着时间的推移,有一些行动需要更长的时间。它每隔几秒发生一次。经过20分钟或更长时间后,Chrome开始提醒setTimeout和requestAnimationFrame花费的时间超过50毫秒。

在Chrome中观察内存图形时,即使手动激活垃圾回收,使用率也会增加,但似乎存在内存泄漏。我的怀疑是这导致了对常规垃圾收集的负载并导致延长的执行时间。

任何想法如何找到并解决这个问题?

open WebSharper 
open WebSharper.JavaScript 
open WebSharper.JQuery 
open WebSharper.UI.Next 
open WebSharper.UI.Next.Client 
open WebSharper.UI.Next.Html 
open WebSharper.UI.Next.Notation 

[<JavaScript>] 
module Client =  
    type IndexTemplate = Templating.Template<"index.html"> 

    type T = { 
     i : int 
     n : float 
     d : float 
    } 

    let Main = 
     JQuery.Of("#main").Empty().Ignore 

     let v = Var.Create { 
      i = 0 
      n = 0.0 
      d = 0.0 
     } 

     let rec f (n : float) = 
      let w = !v 
      v := 
       {w with 
        i = w.i + 1 
        n = n 
        d = n - w.n 
       } 
      s() 
     and s() = 
      JS.RequestAnimationFrame f |> ignore 

     s() 

     div [ 
      div [v.View |> View.Map (fun t -> "Frame " + string t.i) |> textView] 
      div [v.View |> View.Map (fun t -> sprintf "Started: %.1f" t.n) |> textView] 
      div [v.View |> View.Map (fun t -> sprintf "Duration: %.1fms" t.d) |> textView] 
     ] 
     |> Doc.RunById "main" 

我使用Websharper 3.6.20.6,WebSharper.UI.Next 3.6.18.2和Chrome 59.0.3071.115。

回答

2

感谢您的报告中,我认为这与此门票:https://github.com/intellifactory/websharper.ui.next/issues/129

会有一个修复今天WebSharper 4测试版堆栈释放,我们会考虑回移植这样一些重要的改进WebSharper 3.

+0

谢谢。我的项目在修复之前和之后的扎菲尔构建证实了这一变化是有效的。垃圾回收回收分配的内存并保持性能。 – cadull