Page 1 of 1

memory::allocHeap/3->

Posted: 13 Mar 2019 22:39
by Martin Meyer
Hello Thomas,

just a little thing I found in upgrading my code to VIP 9:

In the declaration of predicate memory::allocHeap/3-> the (I suppose intended) default for ContextType is missing.

Re: memory::allocHeap/3->

Posted: 13 Mar 2019 23:32
by Thomas Linder Puls
Actually, it is not possible to supply a default value to that predicate, because then it would conflict with allocHead/2->.

Re: memory::allocHeap/3->

Posted: 14 Mar 2019 1:18
by Martin Meyer
Yes, I see.

It came to my attention because my calls in VIP 8 to

Code: Select all

predicates     allocHeap : (byteCount Size, boolean Atomic) -> pointer Block.
needed to be modified for VIP 9.

Re: memory::allocHeap/3->

Posted: 14 Mar 2019 12:27
by Thomas Linder Puls
Yes, that is unfortunate.

I don't know what you are allocating. But you should notice that many things can be allocated using these polymorphic predicates:

Code: Select all

predicates     alloc_kind : (memoryKind MemoryKind, context ContextType = contextType_pfc)         -> PointerType Allocated.     % @short Allocates an array of #PointerType with #Count elements.     % #Allocated points to the first element in the array. The memory is cleared.     % @end   predicates     alloc_kind_array : (memoryKind MemoryKind, positive Count, context ContextType = contextType_pfc)         -> PointerType Allocated.     % @short Allocates an array of #PointerType with #Count elements.     % #Allocated points to the first element in the array. The memory is cleared.     % @end   predicates     alloc : (context ContextType = contextType_pfc) -> PointerType Allocated.     alloc_atomic : (context ContextType = contextType_pfc) -> PointerType Allocated.     alloc_uncollectable : (context ContextType = contextType_pfc) -> PointerType Allocated.     % @short Allocates a value of #PointerType.  The memory is cleared.     % @end

Re: memory::allocHeap/3->

Posted: 15 Mar 2019 0:24
by Martin Meyer
'My' use of memory::allocHeap is in a customized version of arrayM. In arrayM.pro you have changed the call in VIP 9 to

Code: Select all

data := memory::allocHeap(ByteSize, ma:isAtomic, memory::contextType_pfc)
And so did I in my customized version :D

The customized copy of the arrayM class is of course not really part of the pfc. So would another context type suite better for me? Is there a context number range intended/reserved for being defined in applications?

Re: memory::allocHeap/3->

Posted: 15 Mar 2019 9:52
by Thomas Linder Puls
Memory contexts are only interesting if and when you use the memory profiler. And you can easily track down your allocations and change context (which is typically something you do anyways when you are profiling).

I.e. it is not very important which context you use.