unmanaged memory

  • Thread starter Thread starter Empi
  • Start date Start date
E

Empi

Hi,

Should I use unmanaged memory when I work with the coredll?
If not - is there no chance .net will allocate uncontinous blocks of bytes,
and the dll
will refer to a wrong address ?

Thanks.
 
"coredll" is really ambiguous. P/Invokes don't inherently require using
unmanaged memory, but some do. Depends on what API you're calling.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
I specificallt meant I/O functions such as ReadFile and WriteFile that gets
a Byte buffer,
but more important, how do I know which one might geperdise software's
stability?
Shouldn't I - just in order to be on the safe side - always pass unmanaged
memory?

Thanks.
 
ReadFIle and WriteFile are blocking calls, so the buffer you pass in can not
be moved by the GC until after the P/Invoke has returned. That means that
that specifc call is safe without manual allocation.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
Back
Top