Discussions related to Visual Prolog
Martin Meyer
VIP Member
Posts: 328
Joined: 14 Nov 2002 0:01

memory::allocHeap/3->

Unread post 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.
Regards Martin
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: memory::allocHeap/3->

Unread post 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->.
Regards Thomas Linder Puls
PDC
Martin Meyer
VIP Member
Posts: 328
Joined: 14 Nov 2002 0:01

Re: memory::allocHeap/3->

Unread post 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.
Regards Martin
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: memory::allocHeap/3->

Unread post 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
Regards Thomas Linder Puls
PDC
Martin Meyer
VIP Member
Posts: 328
Joined: 14 Nov 2002 0:01

Re: memory::allocHeap/3->

Unread post 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?
Regards Martin
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: memory::allocHeap/3->

Unread post 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.
Regards Thomas Linder Puls
PDC
Post Reply