Re: To Pin or Copy memory?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I believe that depends on the number of times the win32 API is being called.
If it is called just a couple of times, then it wont matter at all what
method is used. If it is however used in a loop or otherwise called a
ignorant number of times, then the choice will matter. It also depends on
the size of the data that is to be passed.

---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions,explorer bars and BHOs
rapidly in .Net
---------



"obiwanjacobi" <obiwanjacobi@xxxxxxxxxxx> wrote in message
news:1178104412.537061.252340@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

I'm trying to decide what is the best way to pass a data structure to
a P/Invoked Win32 function.

As far as I can tell there are two options:
1) Use the Marshal class to allocate native memory an copy the data
into it.
2) Use the GCHandle to pin a managed object that has the exact same
layout.

I know that pinning will hinder the GC's efficiency. Allocating native
memory will increase the 'memory pressure' for the GC but not
interfere with its collection strategies and it requires additional
copy instructions to move the data.

So whats the best choice when both performance and memory management
efficiency are important?

Thanx
Marc Jacobi



.



Relevant Pages

  • Re: How do I: Main thread spawn child threads, which child processes...control those child processe
    ... is that memory free'd when I use one of the exec*() functions? ... shell was fork/exec'ed by the shell. ... communications through a single pipe, but if portability is a concern ...
    (comp.unix.programmer)
  • Crunchgen (Was Re: actual boot device)
    ... > loader into the image - it is already packed enough. ... a shell and basic binaries into memory for administrative purposes ... patching techniques (patching on output of a tool, ...
    (freebsd-hackers)
  • Re: shell damage
    ... Is CPU and Memory a similar ... The normal solution is that this is _usually_ handled at the shell ... -S use the `soft' resource limit ...
    (comp.unix.bsd.openbsd.misc)
  • Re: shell damage
    ... Is CPU and Memory a similar ... The normal solution is that this is _usually_ handled at the shell ... -S use the `soft' resource limit ...
    (comp.unix.bsd.openbsd.misc)
  • Re: Fast file access
    ... int Size); ... unsigned char* data; ... CreateFile and relatives are part of the Win32 API, ... I have tested the same with memory mapped files and the first access is ...
    (microsoft.public.pocketpc.developer)