1

I'm working on a electrocardiogram diagram with CocosSharp 2D Lolipop 5.1 API22. I have 332 measures per second. I Draw a 6425 lines polygon 100 times per second. I have a Out Of Memory Error at 82 seconds.

            drawNode.DrawPolygon(verts,
            count: verts.Length,
            fillColor: CCColor4B.Transparent,
            borderWidth: 1,
            borderColor: lineColor,
            closePolygon: false);

verts is a 6425 CCPoint array.

X increment is 0.1 pt. y is between 0 and 4500.

enter image description here

I'm under visual studio Entreprise 2015 Update 2

I test my app with Xamarin Android player

Is there a tools I could use in Visual Studio to analysis my issue ?

I read many issues of Memory Leak with this techno but never in CCDrawNode.

  • Any chance your code is available somewhere on github so we could investigate/contribute ? – arnaud del. Jun 30 '16 at 12:37
  • Laurent perso im facing a simular problem, i want to draw a chart like you but after a few minutes of drawing everything get really laggy. While the thread setting up the screen keeps well under 10ms(more like 0.1ms). Did you resolve this or did you move to a different graphics engine? – ikwillem Jul 11 '20 at 12:12

1 Answers1

-1

Xamarin profiler is available for VS enterprise editions and Xamarin studio. https://www.xamarin.com/profiler

When the lines are not on the screen anymore, you would need to remove the nodes from the scene so the garbage collector gets it. You cannot just hide the nodes. You need to remove them and make sure there are no references to them.

Update - Feb 2021, There is most likely a bug in the Cocos implementation. Unfortunately it does not really matter because this project is not supported any more. It has been over five years since any significant activity has been done on this project.

jaybers
  • 1,991
  • 13
  • 18
  • I added one nested CCDRawNode inside mine to do as you suggest. It'better, the out of memory occurs at 240 seconds. I need a command to ensure all is really removed from memory. Something like ResetChildren... – Laurent Perso Jun 26 '16 at 15:03
  • You can have it removed from the scene but still be in memory. Does anything still have a reference to it? For example is it contained in c# collection such as a list? – jaybers Jun 26 '16 at 15:45
  • In fact, it's not directly added to the scene, its encapulated inside multiples nodes Scene->Slots[]->MyChart->Children->DrawNode->DrawableNode I draw lines into DrawableNode – Laurent Perso Jun 26 '16 at 15:52
  • Now I use Task but it's not better : var tsk = Task.Run(() => { RefreshSlots(); }); tsk.Wait(); – Laurent Perso Jun 26 '16 at 15:56
  • Task will essentially run it in a thread. It won't effect when an object gets disposed. it's difficult to diagnose without seeing the complete code but it sounds like something still has a reference to one of your old slots. – jaybers Jun 26 '16 at 16:21
  • This Stack Overflow Editor is a real shame.................................................... Doc telle new line is two spaces and it doesn't work. Ok for my issue, I added this code CCNode dn = Children.Where(x => x.Name == heartChartDrawingName).SingleOrDefault(); if (dn != null) { dn.Cleanup(); dn.RemoveAllChildren(); dn.RemoveFromParent(); } dn = new CCNode(); dn.Name = heartChartDrawingName; After remove all children, they remains. – Laurent Perso Jun 26 '16 at 18:16
  • I cleaned all DrawNodes, I reduced the deep of objects hierarchy, it's better but the issue remains... I think something is wrong in the sources of cocos. I tryed to get the source on git but some dependencies are missing. – Laurent Perso Jun 27 '16 at 03:47