FIX for high cpu usage

Home Forums Forum English (EN) FIX for high cpu usage

  • This topic contains 3 replies, has 1 voice, and was last updated by  Pierre33 3 weeks, 2 days ago.
  • Author
  • #11773 Reply


    Hi Sébastien,
    you are using a busy loop and therefore blocking a whole core. See

    private void PageHandler(OpenSource.UPnP.UPnPDevice sender, OpenSource.UPnP.HTTPMessage msg, OpenSource.UPnP.HTTPSession WebSession, string VirtualDir) {
    // ...
    while (!sessionMp3Streams.TryRemove(s.SessionID, out value)) ;;

    A quick fix is to use wait handlers. Change the loop to

    while (!sessionMp3Streams.TryRemove(s.SessionID, out value))

    and declare

    private static EventWaitHandle ewh = new EventWaitHandle(false, EventResetMode.AutoReset);

    After writing to sessionMp3Streams use ewh.Set(); E.g.

    PipeStream stream = sessionMp3Streams.GetOrAdd(WebSession.SessionID, new PipeStream());


    Parallel.ForEach<PipeStream>(sessionMp3Streams.Values, (p, s, l) =>
         p.Write(bufferMp3, 0, bytesRead);

    Now the usage is at most 3% instead of 100%…

    #11802 Reply


    Can this be fixed Sébastien? Experiencing problems as well.

    #12174 Reply


    I’ve installed 1.4 and it’s using 36-45% of my cpu, even when I’m not playing any music. I also don’t see any recent activity on the Forum. If Sebastien is no longer doing development, perhaps “slash” above could produce a version with the fix?

    #13075 Reply


    same here : SWYH using 35% of CPU, resulting in music played sometimes freezing or lagging
    do you have a fix for that that us newbies could use ?
    thanks in advance:)

Reply To: FIX for high cpu usage
Your information:

Posted in