Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 Discussions

Using Compaq Array Visualizer from Delphi .exe, heap management

Elias_Sabbagh
Beginner
1,241 Views
0 Kudos
2 Replies
Intel_C_Intel
Employee
1,241 Views
Hi Elias,
aglMalloc() andaglMallocEx() actually create a shared memory object to store the array data. This allows other processes (e.g. the Array Viewer) to access the data without having to make a copy of the data each time the array is udpated. But as long as you pair aglMalloc() with aglFree() it should work ok.
aglReshape() should just change some header bytes in the memory allocated by aglMalloc(), it won't grow or shrink the memory. i.e. you can use aglReshape to change a one-dimensional 100 element array into a two-dimensional 10x10 element array. So I wouldn't think there could be any danger of aglReshape() corrupting the Delphi heap.
When you call aglReshape() are you sure that agl160.dll is getting a pointer to the first element of thedimensions array? And that Delphi is using 4-byte integers? AV won't hang on to the dimensions array pointer, so you're free to release it once the call completes.
John
0 Kudos
Elias_Sabbagh
Beginner
1,241 Views
John-
I guess that the problem is that my Delphiprototype forthe aglReshape() call isn't correct,because a) Delphi uses 4-byte integers, and b) I'm pretty sure that I'm passing the dynamically-allocated array from Delphi properly. Hmm...
Actually, I'm less sure about part b. There's a bit of fiddling that needs to be done to get the address of the start of the data when dealing with Delphi dynamic arrays, since they're reference-counted, and the count is stored at the front of the object. You can't just pass a pointer to the array; you have to pass a pointer to the 0'th element. Perhaps I've screwed that up...
Anyway, thanks for the glimpse into the internals of the "agl" API.
Elias Sabbagh
0 Kudos
Reply