Click here to Skip to main content
15,900,258 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Managed and Unmanaged structures Pin
-=jarl=-26-Feb-03 23:16
-=jarl=-26-Feb-03 23:16 
GeneralRe: Managed and Unmanaged structures Pin
Paul Selormey27-Feb-03 0:20
Paul Selormey27-Feb-03 0:20 
GeneralRe: Managed and Unmanaged structures Pin
-=jarl=-27-Feb-03 0:22
-=jarl=-27-Feb-03 0:22 
GeneralManaged/Unmanaged: pinning ptr madness Pin
VizOne25-Feb-03 22:04
VizOne25-Feb-03 22:04 
GeneralRe: Managed/Unmanaged: pinning ptr madness Pin
Jeff J26-Feb-03 16:24
Jeff J26-Feb-03 16:24 
GeneralRe: Managed/Unmanaged: pinning ptr madness Pin
VizOne27-Feb-03 1:56
VizOne27-Feb-03 1:56 
GeneralRe: Managed/Unmanaged: pinning ptr madness Pin
VizOne28-Feb-03 0:31
VizOne28-Feb-03 0:31 
GeneralRe: Managed/Unmanaged: pinning ptr madness Pin
Jeff J28-Feb-03 22:25
Jeff J28-Feb-03 22:25 
Hi VizOne,

Sorry for the late reply.

VizOne wrote:
But what about __value object? They are stored on stack, aren't they? Will stack object be move during collection, too?

Although __value objects are typically stored on the stack, they can also be put on the heap. Stack objects are the same in .Net as they are in regular C/C++, so they won't move.

How heavy would you say is pinning a pointer? Is it a real performance issue if I keep the pointer pinned only for some native calculations that won't last more then a view microseconds?

I did some preliminary tests too, and I could barely measure any performance differences. I forced GC collections during them. The GC does not collect very often under normal circumstances, so I don't see pinning as costly either. Your tests jibe with mine.

Of course reinterpret_cast is an evil monster, but I have to use it here, haven't I?

I always do, and MC++ code that ships with .Net uses it too. I really think MS is just playing it "safe". As I recall, reinterpret_cast was just discouraged. The software world would grind to a halt if such casts were never used Wink | ;)

The reinterpret_cast is safe and ok, or not?

I usually call native functions from MC++ much like you do. As long as managed objects are pinned and the cast is appropriate, safety should not be of concern.

Cheers
GeneralImplementing IDisposable Pin
VizOne24-Feb-03 9:49
VizOne24-Feb-03 9:49 
GeneralRe: Implementing IDisposable Pin
Paul Selormey25-Feb-03 0:23
Paul Selormey25-Feb-03 0:23 
GeneralRe: Implementing IDisposable Pin
VizOne25-Feb-03 0:30
VizOne25-Feb-03 0:30 
GeneralRe: Implementing IDisposable Pin
Paul Selormey25-Feb-03 0:49
Paul Selormey25-Feb-03 0:49 
GeneralRe: Implementing IDisposable Pin
VizOne25-Feb-03 0:58
VizOne25-Feb-03 0:58 
GeneralRe: Implementing IDisposable Pin
Paul Selormey25-Feb-03 1:48
Paul Selormey25-Feb-03 1:48 
GeneralRe: Implementing IDisposable Pin
VizOne25-Feb-03 2:45
VizOne25-Feb-03 2:45 
GeneralRe: Implementing IDisposable Pin
Paul Selormey25-Feb-03 2:54
Paul Selormey25-Feb-03 2:54 
QuestionManaged type??? Pin
Orkun GEDiK21-Feb-03 12:49
Orkun GEDiK21-Feb-03 12:49 
AnswerRe: Managed type??? Pin
Paul Selormey23-Feb-03 1:46
Paul Selormey23-Feb-03 1:46 
GeneralRe: Managed type??? Pin
Orkun GEDiK23-Feb-03 3:55
Orkun GEDiK23-Feb-03 3:55 
GeneralRe: Managed type??? Pin
Paul Selormey23-Feb-03 23:49
Paul Selormey23-Feb-03 23:49 
GeneralRe: Managed type??? Pin
Orkun GEDiK24-Feb-03 10:48
Orkun GEDiK24-Feb-03 10:48 
GeneralRe: Managed type??? Pin
Paul Selormey25-Feb-03 0:30
Paul Selormey25-Feb-03 0:30 
GeneralRe: Managed type??? Pin
Orkun GEDiK25-Feb-03 10:59
Orkun GEDiK25-Feb-03 10:59 
GeneralAppDomain question... Pin
Orkun GEDiK21-Feb-03 11:28
Orkun GEDiK21-Feb-03 11:28 
GeneralProblems working witk wav data files Pin
matlab21-Feb-03 4:03
matlab21-Feb-03 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.