Disposing PointCloud

As in topic. @dale is there any specific way of disposing pointclouds?

I’m doing it more or less like this i launch event when i have a new batch of data to display i’m cleaning old buffer > creating new > putting required geometry into it then it is picked by display conduit.

The thing is that when i Dispose pointcloud and create new into its place old one seems to be stuck in some other place since when orbiting old cloud is shown with new one - like they would swap constantly / flickers. I didn’t notice anything like that for meshes or lines.

The only way around i found so far is to set all pointcloud items location to Unset but it causes significant performance drop …

Dropping here vid showing the problem https://aws1.discourse-cdn.com/mcneel/uploads/default/original/3X/2/1/21b20b5d6edbcd72ccfa1c86f0f4a113988c6a54.mp4

No, you can can dispose of point clouds in RhinoCommon the same way you dispose of any other object type.

As for flickers, if you are constantly replacing point clouds and redrawing, I’m not sure what else you’d expect. Of course, if you have some code you don’t think work as it should, we’re always happy to review.

– Dale

Umm… I’m not. Buffer change doesn’t happen during redraw or between frames. Buffer isn’t drawn until it is ready, so my code isn’t referencing the previous cloud at all during the next redraw routine. Before creating a new cloud old is disposed ( at least in my code ) - so it looks like it stucks/leaks somewhere in rhino internal buffer.

Hi @D-W,

With what you’ve provided, I don’t see how we can help you. If this issue is important to you, then please provide us a working code sample that allows us to replicate what you are seeing. Without this, I don’t know how else to help - sorry.

Thanks,

– Dale

Hi @dale it looks like someone fixed this issue however now i get tons of AccessViolationExceptions i was fighting with it for few days however it happens at level of RhinoCommon.dll…

Would you mind explaining how to rapidly change objects for display pipeline? From my observation it is happening when i dispose old and creating instances of new ones. During this conduit overrides are returned - if(isUpdating) return. So for display it should never be reachable during redrawing so where those AccessViolationExceptions are if not in sth cached on SDK side?

Hi @D-W,

Probably not, as I cannot think of a feature in Rhino that draws in this manner.

I’ll once again call for a sample that repeats the problem. I don’t see us getting anywhere without one.

– Dale

Hi @D-W,

A couple of things to consider and/or try:

1.) Make sure to call the Dispose member of point clouds so they are destroyed immediately.
2.) When deleting objects, you might want to lock your collection.
3.) When inside a conduit method, set a flag indicating that you are drawing, and clear it when you leave.

protected override void DrawOverlay(DrawEventArgs e)
{
  CondutExecuting = true;
  // todo...
  ConduitExecuting = false;
}

The code and refreshes the data structure should check this flag and do nothing if set.

– Dale

Hi @dale,

I understand that confidential PM isnt an option. I’m disposing them. I did all from above. My
if (isUpdating) return; is equivalent of yours CondutExecuting. I’m disposing meshes too. Just for being clear those aren’t part of any doc those are objects only for use without a doc. I will wrap example in a minute. I will try to not dispose and will see if i get the same exception or will hit out of mem.

Hi @dale,

ok i guess its solved - took out SpinUntil from the lock and feed it with CancelationToken - Quick cancelations and disposing sometimes still throws it but way less. Thanks for bringing CondutExecuting back to my mind i used both approaches and seems a looot more stable now.