【问题标题】:Slowing performance in Websharper application, possible memory leakWebshaper 应用程序性能下降,可能存在内存泄漏
【发布时间】:2017-07-17 08:44:04
【问题描述】:

以下单页 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。

【问题讨论】:

    标签: f# websharper websharper.ui.next


    【解决方案1】:

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

    今天将发布一个带有修复程序的 WebSharper 4 beta 堆栈版本,我们将研究将类似这样的一些重要改进向后移植到 WebSharper 3。

    【讨论】:

    • 谢谢。我的项目在修复之前和之后的 Zafir 构建确认更改有效。垃圾收集回收分配的内存并保持性能。
    猜你喜欢
    • 1970-01-01
    • 2011-01-03
    • 1970-01-01
    • 1970-01-01
    • 2011-04-18
    • 1970-01-01
    • 2023-03-29
    相关资源
    最近更新 更多