필터 지우기
필터 지우기

size(libpointer.Value). Can it be done *without* copying the array

조회 수: 1 (최근 30일)
Thomas Carpenter
Thomas Carpenter 2015년 3월 20일
편집: Thomas Carpenter 2015년 3월 20일
Hi,
I am returning a pointer to an array to MATLAB from a DLL using the following (simplified) code:
arrayWidth = 16;
wordsRequired = 16*2048*1024*16*16; %16GB of uint16's
bufferPtr = lib.pointer('uint16Ptr'); %Null Pointer
status = calllib('TestLib','GetBuffer',bufferPtr, wordsRequired);
if (status >= 0)
setdatatype(bufferPtr,'uint16Ptr',arrayWidth,wordsRequired/arrayWidth); %Set size
wasSuccessful = 1;
end
That all works fine, I get the pointer back and status from my library tells me that there was enough data in the buffer for the requested length.
Now, just to make sure, I did the following:
size(bufferPtr.Value());
Expecting that to tell me the size - which it should as I used setdatatype. It tells me the correct values
ans = 16 536870912
Excellent.
BUT
What it also does, which I really don't want and have no idea why on earth it would do, is first make a local copy of the ENTIRE 16GB array. So it spends 30 seconds copying 16GB of RAM just to tell me two numbers which I told it on the line above.
Is there any way to get the size of a libpointer value without it copying it?
(p.s. I'm using 64bin Win7 with MATLAB 2013a)

답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by