Memory cost expensive for SketchUp C API


#1

Hi Expert,

There are 484471 faces in the created SketchUp model. I don’t attach this model because its size is 80M. I just share it here “\\shacng109wqm5\share\perf\13-00 asm_1.skp”.

From the following result when create this SketchUp model, we can see the peak memory cost(364M and 520M) happened in the SketchUp API is expensive. I want to know whether the memory cost is as designed or not.

I am just curious why calling SUEntitiesFill(…) costs 520M. From my point of view, all faces have been added into the geometry input.

  1. Add all faces into SUGeometryInputRef object by following SketchUp API: cost 364M
    SULoopInputCreate(SULoopInputRef* loop_input)
    SUGeometryInputAddVertex(SUGeometryInputRef geom_input, const struct SUPoint3D* point)
    SULoopInputAddVertexIndex(SULoopInputRef loop_input, size_t vertex_index)
    SUGeometryInputAddFace(SUGeometryInputRef geom_input, SULoopInputRef* outer_loop, size_t* added_face_index)

  2. Add SUGeometryInputRef object into model by the following API: cost 520M
    SUEntitiesFill(SUEntitiesRef entities, SUGeometryInputRef geom_input, true)


#2

The link does not work.


#3

SUGeometryInput just holds some temporary data structures to be used as input to SUEntitiesFill, which then takes this input and turns it into actual internal SketchUp data structures. After the call, you need to delete the geometry input object but you’ll still have all the geometry in the model. What’s the memory usage after that?


#4

For Geo, sorry for the link. If you still need the model, I will send you by other way later.

For bugra, I can assume that calling SUEntitiesFill(…) should cause one copy for all temporary data structures in SUGeometryInput, am I correct? Even if so, there is still 156M(520M-364M) more memory cost when calling SUEntitiesFill(…). Is there other operation to cost 156M more memory?

In addition, I also call SUGeometryInputRelease(…) for SUGeometryInput. It does release 271M. But there is still 93M(364M-271M) not released. Is there any memory leak here?


#5

By all means please do.
Curious how 484,471 faces = 80MB


#6

Interesting. I would be surprised if there is a memory leak because it just uses regular std::vector storage internally. But I’ll double check.


#7

It’s not really a copy, it takes rudimentary input data structures (i.e. SUGeometryInputRef) and turns it into real SketchUp data structures. It is hard to say whether 156MB is warranted for the model you are looking at. Data structures are pretty complicated.


#8

I’m not sure if I am having the same issue or not. But I have noticed that when using SUEntitiesFill in windows 8, it is a lot slower than windows 7. I create a vector of SUGeometryInputRef, it has some 10,000 geo inputs. In windows 7 it takes less than 3 seconds. In windows 8 it takes a little over 30 seconds! Any thoughts?

    SUEntitiesRef entities = SU_INVALID;
    SUModelGetEntities(model, &entities);
    
    size_t count = geo_input.size();
    
    for(size_t i=0; i < count; i++){
    	SUEntitiesFill(entities, geo_input[i], true);
    }

@bugra @tt_su


#9

We had some reports of such slowdowns with certain virus protection programs. Can you try again with it disabled?


#10

I just did. It was the Windows Defender that is slowing it down. Thanks!


#11

So…what is the work around with something like that, other than disabling it or adding sketchup.exe to the protection program. Is there anything I can add in my code that will work around this?


#12

We don’t have a viable workaround at the moment but we have the issue logged. We haven’t yet had luck duplicating such dramatic slow downs.