Hi,

I need an DMA-Buffer on an X86 System which does not ly in the process
address space. Finaly I managed thi with the help of Mike Hall in the
following way:

dma_pci.InterfaceType=PCIBus;
dma_pci.BusNumber=0;
dma_pci.ObjectSize=sizeof(DMA_ADAPTER_OBJECT);
LPVOID pVA = HalAllocateCommonBuffer( &dma_pci, size,
&(Buffers[bufferIndex].dmaAdress), false);

LPVOID pVAShared = VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS);
VirtualCopy (pVAShared, pVA , size , PAGE_NOCACHE | PAGE_READWRITE);
VirtualFree (pVA, 0, MEM_RELEASE);

return pVAShared;


But If I try to frre pVAShared with VirtualFree it doesn't work. I don't get
an error, but not all Memory is freed, even after exit of the process.

Any Idea?

Best regards

Thomas

Re: VirtualFree doen't free Memory by Rick

Rick
Tue Jun 01 15:46:26 CDT 2004

On Tue, 1 Jun 2004 16:23:06 +0200, "Thomas Pfrengle"
<t.pfrengle@nospam.hbs-jena.com> wrote:

>Hi,
>
>I need an DMA-Buffer on an X86 System which does not ly in the process
>address space. Finaly I managed thi with the help of Mike Hall in the
>following way:
>
> dma_pci.InterfaceType=PCIBus;
> dma_pci.BusNumber=0;
> dma_pci.ObjectSize=sizeof(DMA_ADAPTER_OBJECT);
> LPVOID pVA = HalAllocateCommonBuffer( &dma_pci, size,
> &(Buffers[bufferIndex].dmaAdress), false);
>
> LPVOID pVAShared = VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS);
> VirtualCopy (pVAShared, pVA , size , PAGE_NOCACHE | PAGE_READWRITE);
> VirtualFree (pVA, 0, MEM_RELEASE);
>
> return pVAShared;
>
>
>But If I try to frre pVAShared with VirtualFree it doesn't work. I don't get
>an error, but not all Memory is freed, even after exit of the process.
>
>Any Idea?
>
>Best regards
>
>Thomas
>
Just from looking through the code I'm not sure that VirutalFree is
the correct way to free memory allocated by
HallAllocateCommonBuffer(). You probably need to free this using
HalFreeCommonBuffer(). See if that plugs your leak.


Re: VirtualFree doen't free Memory by Thomas

Thomas
Wed Jun 02 05:47:54 CDT 2004

Hi Rick,

I tried also HalFreeCommonBuffers, same result

Best regards

Thomas

"Rick" <Rick.Noriega@Sypris.com> schrieb im Newsbeitrag
news:fgqpb0l02kofjng7khaegqergsf4nvc4at@4ax.com...
> On Tue, 1 Jun 2004 16:23:06 +0200, "Thomas Pfrengle"
> <t.pfrengle@nospam.hbs-jena.com> wrote:
>
> >Hi,
> >
> >I need an DMA-Buffer on an X86 System which does not ly in the process
> >address space. Finaly I managed thi with the help of Mike Hall in the
> >following way:
> >
> > dma_pci.InterfaceType=PCIBus;
> > dma_pci.BusNumber=0;
> > dma_pci.ObjectSize=sizeof(DMA_ADAPTER_OBJECT);
> > LPVOID pVA = HalAllocateCommonBuffer( &dma_pci, size,
> > &(Buffers[bufferIndex].dmaAdress), false);
> >
> > LPVOID pVAShared = VirtualAlloc(NULL, size, MEM_RESERVE,
PAGE_NOACCESS);
> > VirtualCopy (pVAShared, pVA , size , PAGE_NOCACHE | PAGE_READWRITE);
> > VirtualFree (pVA, 0, MEM_RELEASE);
> >
> > return pVAShared;
> >
> >
> >But If I try to frre pVAShared with VirtualFree it doesn't work. I don't
get
> >an error, but not all Memory is freed, even after exit of the process.
> >
> >Any Idea?
> >
> >Best regards
> >
> >Thomas
> >
> Just from looking through the code I'm not sure that VirutalFree is
> the correct way to free memory allocated by
> HallAllocateCommonBuffer(). You probably need to free this using
> HalFreeCommonBuffer(). See if that plugs your leak.
>