Re: MQ interface - Why are some structures allocated to not cross 64k boundary?
Frankly, we cannot tell the exact rationale. I have taken over the
responsibility for the MQ interface, but that was quite some time
after the early developers finished the first implementations. I
have asked the developers but none of them can remember back to 2004
when they released it. I have also consulted the "WebSphere MQ -
Application Programming Reference" but I couldn't spot any
information that justifies the 64k alignment enforced with
I simply gave it a try and ran our SUnit tests after disabling the
alignment in #alloc64KAligned: and inserting a notification if
repeated allocation should have happened. Here is the code:
"Perform the allocation method <aSymbol>.
Make sure the allocated memory does not span a multiple of 64K.
Return: CCompositePointer "
| sixtyFourK gcProtected |
sixtyFourK := 64 * 1024.
gcProtected := nil.
[| heapPtr structSize startAddr |
heapPtr := self perform: aSymbol.
structSize := heapPtr type referentType sizeof.
startAddr := heapPtr referentAddress.
startAddr \\ sixtyFourK + structSize <= sixtyFourK ifTrue: [^heapPtr].
Transcript show: ('Warning: Memory allocation for #<1s> across 64k segments<n>' expandMacrosWith: aSymbol).
true ifTrue: [^heapPtr].
All tests ran successfully and repeated allocation was extremely
rare. Even if the original #alloc64KAligned: would have rejected an
allocation, it was ok to continue with memory spreading over two 64k
segments. The tests covered remote connection and get/put with
queues from a Windows 7 PC to MQ on a linux server.
I'll see what I can do to verify that the alignment is superfluous.
If you have troubles with the repeated allocation you could use the
code above in own tests and check whether repeated allocation is an
issue at all. With my experiences one could also discard all the
alignment and use this code: