[vwnc] [BUG] copyToHeap:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[vwnc] [BUG] copyToHeap:

Nicolas Cellier-3

#copyToHeap: generally allocate too much memory.
This is an old bug not corrected in VW7.7 (never detected ?).
This is due to #malloc: and #gcMalloc: taking NUMBER OF ELEMENTS as argument
... (rather than NUMBER OF BYTES)
But some implementation of #copyToHeap: pass the number of bytes.
For example, a corect version for DWordArray should be:

DWordArray>>copyToHeap: mallocSelector
        | aPointer byteSize numElements |
        byteSize := self basicSize.
        numElements := byteSize / self baseCType referentType dataSize.
        aPointer := self baseCType referentType perform: mallocSelector
                with: numElements.
        aPointer
                copyAt: 0
                from: self
                size: byteSize
                startingAt: 1.
        ^aPointer

Allocating too much memory is less desastrous than too few :)
But hungriest memory eaters might like to patch

Cheers

Nicolas

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [BUG] copyToHeap:

Andres Valloud-6
AR 59343.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Nicolas Cellier
Sent: Thursday, January 21, 2010 5:21 AM
To: [hidden email]
Subject: [vwnc] [BUG] copyToHeap:


#copyToHeap: generally allocate too much memory.
This is an old bug not corrected in VW7.7 (never detected ?).
This is due to #malloc: and #gcMalloc: taking NUMBER OF ELEMENTS as
argument ... (rather than NUMBER OF BYTES) But some implementation of
#copyToHeap: pass the number of bytes.
For example, a corect version for DWordArray should be:

DWordArray>>copyToHeap: mallocSelector
        | aPointer byteSize numElements |
        byteSize := self basicSize.
        numElements := byteSize / self baseCType referentType dataSize.
        aPointer := self baseCType referentType perform: mallocSelector
                with: numElements.
        aPointer
                copyAt: 0
                from: self
                size: byteSize
                startingAt: 1.
        ^aPointer

Allocating too much memory is less desastrous than too few :) But
hungriest memory eaters might like to patch

Cheers

Nicolas

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc