降低 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。

感谢您的报告,我已将其链接到此票:https://github.com/intellifactory/websharper.ui.next/issues/129

今天将有一个带有修复的WebSharper 4测试版堆栈版本,我们将研究将一些重要的改进向后移植到WebSharper 3中。

最新更新