making best use of __gc & __nogc memory(managed c++)

Started by
-1 comments, last by edwinnie 20 years ago
hihi, i was thinking abt this weird scenario: suppose i got: public __value struct Vertex { float pos __nogc[3]; ... }; then i use this to store some of them: public __gc class Cube { Vertex vertices __gc[]; }; then somewhere in the code i did this: Vertex v; //assume initialized with values vertices = new Vertex[8]; vertices[0] = v; //implicit boxing? 1)is there any implicit boxing in this case? 2)notice i used a __gc array to store a __value type, but if the __gc array (vertices) is being cleared by using System::Array::Clear(..), i suppose there arent any leaks rite?even when the __value type has a __nogc[]? 3)i am trying to understand this: a)the Vertex v is allocated on the runtime stack? b)by assigning to the vertices __gc array, the Vertex v is being copied over c)then the Vertex v will from now reside in the GC heap? 4)any better solutions to make things more simple and yet robust would be most appreciated, considering __gc types are slighter slower than __value types, and there is also a need to balance the usage of __gc & __nogc memory so that there wouldnt be any leaks... thx! Edwinz [edited by - edwinnie on May 3, 2004 5:22:25 AM]

This topic is closed to new replies.

Advertisement