Explorar o código

HPCC-15486 Remove unused jmalloc code

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday %!s(int64=9) %!d(string=hai) anos
pai
achega
26a3e5928a

+ 0 - 5
system/jlib/CMakeLists.txt

@@ -67,7 +67,6 @@ set (    SRCS
          jlz4.cpp
          jlzma.cpp 
          jlzw.cpp 
-         jmalloc.cpp 
          jmd5.cpp 
          jmemleak.cpp 
          jmisc.cpp 
@@ -90,7 +89,6 @@ set (    SRCS
          jtime.cpp 
          junicode.cpp 
          jutil.cpp 
-         jvmem.cpp 
          sourcedoc.xml
     )
 
@@ -133,7 +131,6 @@ set (    INCLUDES
         jlzma.hpp
         jlzw.hpp
         jlzw.ipp
-        jmalloc.hpp
         jmd5.hpp
         jmisc.hpp
         jmutex.hpp
@@ -166,11 +163,9 @@ set (    INCLUDES
         jtime.ipp
         junicode.hpp
         jutil.hpp
-        jvmem.hpp
         )
 
 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
-    set_property (SOURCE jmalloc.cpp APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-strict-aliasing")
     set_property (SOURCE jencrypt.cpp APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-strict-aliasing")
 endif ()
 if (CMAKE_COMPILER_IS_GNUCC)

+ 4 - 212
system/jlib/jbuff.cpp

@@ -36,7 +36,6 @@
 #include "jexcept.hpp"
 #include "jmisc.hpp"
 #include "jutil.hpp"
-#include "jvmem.hpp"
 
 #ifdef _DEBUG
 #define KILL_CLEARS_MEMORY  
@@ -45,6 +44,10 @@
 #define TRACE_LARGEMEM_OOM
 #endif
 
+#define VMPAGESIZE     (0x1000)
+#define VMPAGEMASK     (VMPAGESIZE-1)
+#define VMPAGEROUND(s) (((s)+VMPAGEMASK)&~VMPAGEMASK)
+
 
 
 #if 1
@@ -1259,20 +1262,6 @@ void *CLargeMemoryAllocator::nextBuffer(void *prev,size32_t &sz)
     return p->base;
 }
 
-void CJMallocLargeMemoryAllocator::allocchunkmem()
-{
-    chunk.base = (byte *)allocator->allocMem(chunk.max); 
-#ifdef TRACE_LARGEMEM_ALLOC
-    PROGLOG("CJMallocLargeMemoryAllocator::allocchunkmem malloced %d at %p",chunk.max,chunk.base);
-#endif
-}
-
-void CJMallocLargeMemoryAllocator::disposechunkmem() 
-{ 
-    allocator->freeMem(chunk.base); 
-}
-
-
 CFixedSizeAllocator::CFixedSizeAllocator()
 {
     chunklist = NULL;
@@ -1370,200 +1359,3 @@ void CFixedSizeAllocator::stats(size32_t &sizealloc, size32_t &sizeunused)
     sizealloc = numalloc*allocsize;
     sizeunused = numfree*allocsize;
 }
-
-
-//============================================================
-
-#define LARGEST_CONTIGUOUS_BLOCK (0xffff0000)
-
-void CContiguousLargeMemoryAllocator::init(size32_t _totalmax,size32_t _chunkmin,bool _throwexception)
-{
-    throwexception = _throwexception;
-    totalmax = (_totalmax<LARGEST_CONTIGUOUS_BLOCK)?VMPAGEROUND(_totalmax):LARGEST_CONTIGUOUS_BLOCK;
-    chunkmin = _chunkmin;
-    ofs = 0;
-    mapped = 0;
-    base = NULL; 
-#ifdef WIN32
-    LARGE_INTEGER li;
-    li.QuadPart = totalmax; 
-    hmap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE|SEC_RESERVE, li.HighPart, li.LowPart, NULL);
-#endif
-}
-
-CContiguousLargeMemoryAllocator::CContiguousLargeMemoryAllocator()
-{
-    // values overwritten by init
-    throwexception = true;
-    totalmax = 0;
-    chunkmin = 0x1000;
-    ofs = 0;
-    mapped = 0;
-    base = NULL;
-}
-
-CContiguousLargeMemoryAllocator::~CContiguousLargeMemoryAllocator()
-{
-    reset();
-#ifdef WIN32
-    if (hmap) {
-        if (base) 
-            UnmapViewOfFile(base);
-        CloseHandle(hmap);
-    }
-#endif
-}
-
-void *CContiguousLargeMemoryAllocator::getBase()
-{
-    if (!base) {
-#ifdef WIN32
-        if (hmap)
-            base = (byte *) MapViewOfFile(hmap, FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, totalmax);
-        else
-            base = NULL;
-#else
-        base = (byte *) mmap(NULL,totalmax,PROT_NONE,MAP_PRIVATE|MAP_NORESERVE|MAP_ANONYMOUS,-1,0);
-        // create initially with no access
-        if (base == (byte *)MAP_FAILED)
-            base = NULL;
-#endif
-    }
-    return base;
-}
-
-bool CContiguousLargeMemoryAllocator::map(size32_t tot,size32_t sz)
-{
-    getBase();
-    if (!base||(tot>totalmax)) {
-        outOfMem(sz);
-        return false;
-    }
-    if (tot>mapped) {
-        void * a = base+mapped;
-        size32_t tomap = VMPAGEROUND(chunkmin); 
-#ifdef WIN32
-        if (VirtualAlloc(a,tomap,MEM_COMMIT,PAGE_READWRITE)!=a) {
-            outOfMem(sz);
-            return false;
-        }
-#else
-        if (mprotect(a,tomap,PROT_READ|PROT_WRITE)<0) {
-            int err = errno;
-            if ((err==ENOMEM)||(err==EFAULT)) {
-                outOfMem(sz);
-                return false;
-            }
-            WARNLOG("CContiguousLargeMemoryAllocator:map madvise err=%d",err);
-        }
-
-#endif
-        mapped = mapped+tomap;
-    }
-    return true;
-}
-
-
-
-
-void CContiguousLargeMemoryAllocator::unmap()
-{
-    // ensures above ofs is unmapped
-    size32_t ch = VMPAGEROUND(chunkmin);
-    size32_t newmapped = ((ofs+ch-1)/ch)*ch;
-    if (newmapped<mapped) {
-        void * a = base+newmapped;
-#ifdef WIN32
-        if (newmapped==0) { // free completely
-            if (base) {
-                UnmapViewOfFile(base);
-                base = NULL;  
-            }
-        }
-        else {
-            VirtualFree(a,mapped-newmapped,MEM_DECOMMIT); // can't fail
-        }
-#else
-        if (newmapped==0) { // free completely
-            if (base) {
-                munmap(base,totalmax);
-                base = NULL;  
-            }
-        }
-        else {
-            if (mprotect(a,mapped-newmapped,PROT_NONE)<0) 
-                WARNLOG("CContiguousLargeMemoryAllocator:unmap mprotect err=%d",errno);
-//          if (madvise(a,mapped-newmapped,MADV_DONTNEED)<0)  // not sure if this does anything but tell it anyway
-//              WARNLOG("CContiguousLargeMemoryAllocator:unmap madvise err=%d",errno);
-        }
-#endif
-        mapped = newmapped;
-    }
-}
-
-
-void CContiguousLargeMemoryAllocator::reset()
-{
-    reduceSize(ofs);
-}
-
-void CContiguousLargeMemoryAllocator::setSize(size32_t pos)
-{
-    assertex(ofs>=pos);
-    reduceSize(ofs-pos);
-}
-
-void CContiguousLargeMemoryAllocator::reduceSize(size32_t amount)
-{
-    assertex(ofs>=amount);
-    ofs-=amount;
-    unmap();
-}
-
-void *CContiguousLargeMemoryAllocator::nextBuffer(void *prev,size32_t &sz)
-{
-    // have to be careful as approaches 4GB
-
-    byte *p = prev?((byte *)prev):base;
-    size32_t o = p-base;
-    size32_t r = (o<ofs)?ofs-o:0;
-    sz = (r<=chunkmin)?0:(r-chunkmin);
-    if (sz==0)
-        return NULL;
-    if (sz>chunkmin) 
-        sz = chunkmin;
-    return p+chunkmin;
-}
-
-
-byte *CContiguousLargeMemoryAllocator::next(size32_t pos,size32_t &size)
-{
-    if (ofs<=pos) {
-        size = 0;
-        return NULL;
-    }
-    size = ofs-pos;
-    return base+pos;
-}
-
-MemoryBuffer &CContiguousLargeMemoryAllocator::serialize(MemoryBuffer &mb)
-{
-    memcpy(mb.reserveTruncate(ofs),base,ofs);
-    return mb;
-}
-
-MemoryBuffer &CContiguousLargeMemoryAllocator::deserialize(MemoryBuffer &mb,size32_t sz, size32_t extra)
-{
-    mb.read(sz,alloc(sz,extra));
-    return mb;
-}
-
-
-
-
-void CContiguousLargeMemoryAllocator::outOfMem(size32_t sz)
-{
-    if (throwexception) {
-        throw createOutOfMemException(-6,sz, ofs,true);
-    }
-}

+ 0 - 112
system/jlib/jbuff.hpp

@@ -22,7 +22,6 @@
 
 #include "jiface.hpp"
 #include "jmutex.hpp"
-#include "jmalloc.hpp"
 
 class StringAttr;
 class StringBuffer;
@@ -382,95 +381,6 @@ extern jlib_decl MemoryBuffer & serialize(MemoryBuffer & buffer, const char * va
 extern jlib_decl MemoryBuffer & deserialize(MemoryBuffer & buffer, StringAttr & value);
 
 
-class  jlib_decl CContiguousLargeMemoryAllocator
-{
-    // limited to 4GB for the moment
-protected:
-    byte *base;
-    size32_t totalmax;
-    size32_t ofs;
-    size32_t chunkmin;  // only used for next and nextBuffer;
-    size32_t mapped;    // amount of 'real' memory
-    bool throwexception;
-    HANDLE hfile;
-#ifdef WIN32
-    HANDLE hmap;        
-#endif
-
-    void outOfMem(size32_t sz);
-    bool map(size32_t tot,size32_t sz);
-    void unmap();
-
-public:
-    CContiguousLargeMemoryAllocator(size32_t _totalmax,size32_t _chunkmin,bool _throwexception)
-    {
-        init(_totalmax,_chunkmin,_throwexception);
-    }
-
-    CContiguousLargeMemoryAllocator();
-
-    void init(size32_t _totalmax,size32_t _chunkmin,bool _throwexception);
-
-    virtual ~CContiguousLargeMemoryAllocator();
-
-    inline void setTotalMax(size32_t total)
-    {
-        totalmax = total;
-    }
-
-    inline size32_t getTotalMax()
-    {
-        return totalmax;
-    }
-
-    inline bool checkAvail(size32_t sz, size32_t sza=0,size32_t extra=0)
-    {
-        if (sza>sz)
-            sz = sza;
-        if (ofs+sz+extra>mapped) 
-            if (!map(ofs+sz+extra,sz))
-                return false;
-        return true;
-    }
-
-    inline byte *alloc(size32_t sz,size32_t extra=0)
-    {
-        if (mapped<ofs+sz+extra) 
-            if (!map(ofs+sz+extra,sz))
-                return NULL;
-        byte *ret = base+ofs;
-        ofs += sz;
-        return ret;
-    }
-
-
-    inline size32_t allocated()
-    {
-        return ofs;
-    }
-
-    inline size32_t maxallocated()
-    {
-        return mapped;
-    }
-
-    void setChunkGranularity(size32_t sz)
-    {
-        if (sz&&(chunkmin>sz)) 
-            chunkmin -= (chunkmin%sz);
-    }
-
-    void reset();
-    void setSize(size32_t pos);
-    void reduceSize(size32_t amount);
-    byte *next(size32_t pos,size32_t &size); 
-    MemoryBuffer &serialize(MemoryBuffer &mb);
-    MemoryBuffer &deserialize(MemoryBuffer &mb,size32_t sz, size32_t extra=0);
-    void *nextBuffer(void *prev,size32_t &sz);
-    void *getBase();
-};
-
-
 class  jlib_decl CLargeMemoryAllocator
 {
 protected:
@@ -568,28 +478,6 @@ public:
 
 
 
-class  jlib_decl CJMallocLargeMemoryAllocator: public CLargeMemoryAllocator
-{
-    IAllocator *allocator;
-    virtual void allocchunkmem();
-    virtual void disposechunkmem();
-public:
-    CJMallocLargeMemoryAllocator(IAllocator *_allocator,memsize_t _totalmax,size32_t _chunkmin,bool _throwexception)
-        : allocator(_allocator)
-    {
-        allocator = _allocator;
-        allocator->Link();
-        CLargeMemoryAllocator::init(_totalmax,_chunkmin,_throwexception);
-    }
-    ~CJMallocLargeMemoryAllocator()
-    {
-        CLargeMemoryAllocator::reset();
-        allocator->Release();
-    }
-    IAllocator *queryAllocator() { return allocator; }
-
-};
-
 class CLargeMemorySequentialReader
 {
     size32_t left;

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 2053
system/jlib/jmalloc.cpp


+ 0 - 59
system/jlib/jmalloc.hpp

@@ -1,59 +0,0 @@
-/*##############################################################################
-
-    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-############################################################################## */
-
-
-#ifndef JMALLOC_HPP
-#define JMALLOC_HPP
-
-#include "jiface.hpp"
-
-interface IAllocator: extends IInterface
-{
-    virtual void * allocMem(size32_t sz)=0;
-    virtual void   freeMem(void *)=0;
-    virtual void * reallocMem(void *prev,size32_t sz)=0;
-    virtual size32_t usableSize(const void *)=0;  
-    virtual memsize_t totalAllocated()=0;   // amount allocated from OS
-    virtual memsize_t totalMax()=0;         // total that can be allocated from OS
-    virtual memsize_t totalRemaining()=0;   // maximum remaining
-    virtual void checkPtrValid(const void * ptr)=0;   // for debugging only
-    virtual void logMemLeaks(bool logdata)=0; 
-    virtual void * allocMem2(size32_t sz, size32_t &usablesz)=0;               // returns size actually allocated 
-    virtual void * reallocMem2(void *prev,size32_t sz, size32_t &usablesz)=0;   // returns size actually allocated 
-    virtual size32_t roundupSize(size32_t sz)=0; // returns usable size would round up to
-
-};
-
-extern jlib_decl IAllocator *createMemoryAllocator(
-    memsize_t maxtotal,                         // maximum to allocate from OS
-    size32_t maxsuballocsize=1024,              // set to 0 to disable suballocation
-    memsize_t mintotal=0x100000*16,             // above this amount free to OS
-    bool avoidReallocFragmentation=true         // whether reallocMem should avoid fragmenting memory by copying where needed 
-);
-
-extern jlib_decl IAllocator *createGuardedMemoryAllocator( // for debug only!
-    memsize_t maxtotal,                         // maximum to allocate from OS
-    size32_t maxsuballocsize=1024,              // set to 0 to disable suballocation
-    memsize_t mintotal=0x100000*16,             // above this amount free to OS
-    bool avoidReallocFragmentation=true,            // whether reallocMem should avoid fragmenting memory by copying where needed 
-    size32_t guardsize= 32
-);
-
-
-extern jlib_decl void testAllocator();
-
-#endif

+ 0 - 422
system/jlib/jvmem.cpp

@@ -1,422 +0,0 @@
-/*##############################################################################
-
-    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-############################################################################## */
-
-#include "platform.h"
-#include "jlib.hpp"
-#include "jiface.hpp"
-#include "jexcept.hpp"
-#include "jbuff.hpp"
-
-#ifndef WIN32
-#include <sys/mman.h>
-#endif
-
-#include "jvmem.hpp"
-
-class CVMSectionAllocator: public CInterface, implements IVMAllocator 
-{
-protected: friend class CVMAllocator;
-    byte *base;
-    size32_t maxsize;
-    offset_t ofs;
-    struct cFreeItem
-    {
-        cFreeItem *next;
-        size32_t ofs;
-        size32_t size;
-    } freelist;
-
-public:
-    IMPLEMENT_IINTERFACE;
-
-
-    CVMSectionAllocator()
-    {
-        base = NULL;
-        freelist.next = NULL;
-        freelist.size = 0;
-    }
-
-    ~CVMSectionAllocator()
-    {
-#ifdef WIN32
-        if (base)
-            UnmapViewOfFile(base);
-#else
-        if (base)
-            munmap(base, maxsize);
-#endif
-        while (freelist.next) {
-            cFreeItem *p = freelist.next;
-            freelist.next = p->next;
-            delete p;
-        }
-    }
-
-
-    bool init(HANDLE hfile,offset_t _ofs, size32_t size
-#ifdef WIN32
-        ,HANDLE hmap
-#endif
-        )
-    {
-        ofs = _ofs;
-        maxsize = VMPAGEROUND(size);
-        assertex(maxsize==size);
-        freelist.ofs = 0;
-        freelist.size = maxsize;
-        freelist.next = NULL;
-#ifdef WIN32
-        LARGE_INTEGER li;
-        li.QuadPart = _ofs; 
-        base = (byte *) MapViewOfFile(hmap, FILE_MAP_READ|FILE_MAP_WRITE, li.HighPart, li.LowPart, size);
-#else
-        offset_t savedPos = lseek(hfile,0,SEEK_CUR);
-        offset_t length = lseek(hfile,0,SEEK_END);
-        lseek(hfile,savedPos,SEEK_SET);
-        if (length<ofs+maxsize) {
-            if (0 != ftruncate(hfile,ofs+maxsize))
-                throw makeErrnoException(errno, "CVMSectionAllocator truncate");
-        }
-        base = (byte *)mmap(NULL, maxsize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_NORESERVE, hfile, _ofs);
-
-        if (base == (byte *)MAP_FAILED)
-            base = NULL;
-//      memset(base,0xdd,maxsize);
-#endif
-        return base!=NULL;
-    }
-
-    void *alloc(size32_t sz)
-    {
-        sz = VMPAGEROUND(sz);
-        cFreeItem *p = &freelist;
-        cFreeItem *pp = NULL;
-        do {
-            if (sz<=p->size) {
-                void *ret = base+p->ofs;
-                if (sz==p->size) {
-                    if (pp) {
-                        pp->next = p->next;
-                        delete p;
-                    }
-                    else if (p->next) { // p==freelist
-                        p = freelist.next;
-                        freelist = *p;
-                        delete p;
-                    }
-                    else {
-                        freelist.ofs = 0;
-                        freelist.size = 0;
-                    }
-                }
-                else {
-                    p->size-=sz;
-                    p->ofs+=sz;
-                }
-                return ret;
-            }
-            pp = p;
-            p = p->next;
-        } while (p);
-        return NULL;
-    }
-
-    bool dealloc(void *ptr,size32_t sz)
-    {
-        sz = VMPAGEROUND(sz); // was allocated by free
-        if ((memsize_t)ptr<(memsize_t)base)
-            return false;
-        memsize_t mo = (memsize_t)ptr-(memsize_t)base;
-        if (mo>=maxsize)
-            return false;
-        size32_t o = (size32_t)mo;
-        size32_t e = o+sz;
-        assertex(e<=maxsize);   // can't straddle blocks
-        cFreeItem *p = &freelist;
-        cFreeItem *pp = NULL;
-        loop {
-            cFreeItem *n=p->next;
-            if (e<p->ofs) {
-                n = new cFreeItem;
-                *n = *p;
-                p->next = n;
-                p->ofs = o;
-                p->size = sz;
-                break;
-            }
-            if (e==p->ofs) {
-                p->ofs -= sz;
-                p->size += sz;
-                // coalesce prev
-                if (pp&&(pp->ofs+pp->size==p->ofs)) {
-                    pp->size += p->size;
-                    pp->next = n;
-                    delete p;
-                    p=pp;
-                }
-                // fallthrough to coalesce next
-            }
-            else if (o==p->ofs+p->size) {
-                p->size += sz;
-                // fallthrough to coalesce next
-            }
-            else if (n) {
-                pp = p;
-                p = n;
-                n = p->next;
-                continue; // loop from the middle
-            }
-            else {
-                // add to end
-                n = new cFreeItem;
-                p->next = n;
-                n->ofs = o;
-                n->size = sz;
-                n->next = NULL;
-                break;
-            }
-            // coalesce next
-            if (n&&(n->ofs==p->ofs+p->size)) {
-                p->size += n->size;
-                p->next = n->next;
-                delete n;
-            }
-            break;
-        }
-        return true;
-    }
-
-    offset_t allocated() const
-    {
-        const cFreeItem *p = &freelist;
-        offset_t ret=maxsize;
-        do {
-            ret -= p->size;
-            p = p->next;
-        } while (p);
-        return ret;
-    }
-};
-
-#define SECTIONSIZE (64*0x100000)        // 64MB -- assumes multiple of page size
-
-class CVMAllocator: public CInterface, implements IVMAllocator 
-{
-    StringAttr filename;
-    UnsignedArray freesections;
-    IArrayOf<CVMSectionAllocator> sections;
-    HANDLE hfile;
-    offset_t maxsize;
-    offset_t totalallocated;
-    mutable CriticalSection sect;
-
-
-#ifdef WIN32
-    HANDLE hmap;
-#endif
-
-public:
-    IMPLEMENT_IINTERFACE;
-
-    CVMAllocator(const char *_filename,offset_t size)
-        : filename(_filename)
-    {
-        maxsize = size;
-        totalallocated = 0;
-        offset_t normsize = size+SECTIONSIZE-1;
-        unsigned nsections=(unsigned)(normsize/SECTIONSIZE);
-#ifdef WIN32
-        hfile = CreateFile(filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_FLAG_RANDOM_ACCESS, 0);
-        if (hfile == INVALID_HANDLE_VALUE) 
-            throw makeOsExceptionV(GetLastError(), "CVMAllocator(CreateFile) %s", filename);
-        LARGE_INTEGER li;
-        li.QuadPart = nsections*SECTIONSIZE; 
-//      li.LowPart = SetFilePointer(hfile, li.LowPart, &li.HighPart, FILE_BEGIN);
-//      SetEndOfFile(hfile);
-        hmap = CreateFileMapping(hfile, NULL, PAGE_READWRITE, li.HighPart, li.LowPart, NULL);
-#else
-        hfile = _lopen(filename.get(), O_RDWR | O_CREAT | O_TRUNC, 0);
-        if (hfile == -1)
-            throw makeOsExceptionV(GetLastError(), "CMmapLargeMemoryAllocator(CreateFile) %s", filename.get());
-        unlink(filename);   // delete now (linux won't really delete until handle released)
-#endif
-        for (unsigned i=nsections;i;)
-            freesections.append(--i);
-    }
-
-    ~CVMAllocator()
-    {
-        sections.kill();        
-#ifdef WIN32
-        CloseHandle(hmap);
-        CloseHandle(hfile);
-        DeleteFile(filename);
-#else
-        close(hfile);
-#endif
-    }
-
-    void *alloc(size32_t sz)
-    {
-        CriticalBlock block(sect);
-        offset_t nta = totalallocated + sz;
-        if (nta>maxsize)
-            return NULL;
-        void *ret;
-        if (sz>SECTIONSIZE) { // too big, panic and resort to OS!
-            ret = malloc(sz);
-            if (ret) 
-                totalallocated = nta;
-            return ret;
-        }
-        ForEachItemInRev(i,sections) {
-            ret = sections.item(i).alloc(sz);
-            if (ret) {
-                totalallocated = nta;
-                return ret;
-            }
-        }
-        if (freesections.ordinality()==0)
-            return NULL;
-        unsigned s = freesections.popGet();
-        CVMSectionAllocator *section = new CVMSectionAllocator();
-        if (!section)
-            return NULL;
-        if (!section->init(hfile,SECTIONSIZE*(offset_t)s,SECTIONSIZE
-#ifdef WIN32
-            ,hmap
-#endif
-            )) {
-            section->Release();
-            return NULL;
-        }
-        ret = section->alloc(sz); 
-        if (!ret) { // hmm - error?
-            section->Release();
-            return NULL;
-        }
-        totalallocated = nta;
-        sections.append(*section);
-        return ret;
-    }
-    bool dealloc(void *ptr,size32_t sz)
-    {
-        CriticalBlock block(sect);
-        if (!ptr)
-            return true;
-        if (sz>SECTIONSIZE) { // was too big, resorted to OS
-            free(ptr);
-            totalallocated -= sz;
-            return true;
-        }
-        ForEachItemIn(i,sections) {
-            CVMSectionAllocator &section = sections.item(i);
-            if (section.dealloc(ptr,sz)) {
-                if (section.maxsize==section.freelist.size) { // empty
-                    freesections.append((unsigned)(section.ofs/SECTIONSIZE));
-                    sections.remove(i);
-                }
-                totalallocated -= sz;
-                return true;
-            }
-        }
-        return false;
-    }
-
-    offset_t allocated() const
-    {
-        CriticalBlock block(sect);
-        return totalallocated;
-    }
-
-};
-
-IVMAllocator *createVMAllocator(const char *filename,offset_t size)
-{
-    return new CVMAllocator(filename,size);
-}
-
-
-//CVMLargeMemoryAllocator: 
-    
-void CVMLargeMemoryAllocator::allocchunkmem()
-{
-    chunk.base = (byte *)vm->alloc(chunk.max);
-}
-
-void CVMLargeMemoryAllocator::disposechunkmem()
-{
-    vm->dealloc(chunk.base,chunk.max);
-}
-
-
-CVMLargeMemoryAllocator::CVMLargeMemoryAllocator(
-                          IVMAllocator *_vm,    
-                          size32_t _totalmax,
-                          size32_t _chunkmin,
-                          bool _throwexception)
-   : CLargeMemoryAllocator(_totalmax,_chunkmin,_throwexception), vm(_vm)
-{
-}
-
-
-
-
-#ifdef TESTVMEM
-void testVM()
-{
-    Owned<IVMAllocator> vm = createVMAllocator(
-#ifdef WIN32
-        "d:\\vmtemp.$$$",
-#else
-        "/d$/vmtemp.$$$",
-#endif
-        0x40000000*2U);
-    unsigned n = SECTIONSIZE/VMPAGESIZE;
-    void **ptrs = new void *[n];
-    unsigned *sizes = new unsigned[n];
-    size32_t allocated=0;
-    unsigned i;
-    for (i=0;i<n;i++) {
-        allocated += (i+1)*VMPAGESIZE;
-        ptrs[i] = vm->alloc((i+1)*VMPAGESIZE);
-        if (!ptrs[i])
-            break;
-    }
-    printf("allocated %u in %d blocks\n",allocated,n);
-    printf("sleeping...\n");
-    Sleep(1000*60);
-    printf("slept\n");
-    n = i;
-    for (i=n;i;i--)
-        ptrs[i-1] = memset(ptrs[i-1],i%17,i*VMPAGESIZE);
-    printf("written %u\n",allocated);
-    printf("sleeping...\n");
-    Sleep(1000*60);
-    printf("slept\n");
-    for (i=0;i<n;i++) {
-        if (i==n-1)
-            printf("last\n");
-        if (!vm->dealloc(ptrs[i],(i+1)*VMPAGESIZE))
-            printf("not deallocated %d\n",i);
-    }
-    printf("deallocated %u now allocated =%" I64F "d\n",allocated,vm->allocated());
-    delete [] sizes;
-    delete [] ptrs;
-}
-#endif

+ 0 - 56
system/jlib/jvmem.hpp

@@ -1,56 +0,0 @@
-/*##############################################################################
-
-    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
-
-    Licensed under the Apache License, Version 2.0 (the "License");
-    you may not use this file except in compliance with the License.
-    You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-############################################################################## */
-
-
-#ifndef JVMEM_HPP
-#define JVMEM_HPP
-
-#include "jiface.hpp"
-
-interface IVMAllocator: extends IInterface
-{
-    virtual void *alloc(size32_t sz)=0;             // allocates multiples of VMPAGESIZE (i.e. rounds up)
-    virtual bool dealloc(void *p,size32_t sz)=0;    // size must be the size allocated
-    virtual offset_t allocated() const = 0;         // total allocated
-};
-
-#define VMPAGESIZE     (0x1000) 
-#define VMPAGEMASK     (VMPAGESIZE-1) 
-#define VMPAGEROUND(s) (((s)+VMPAGEMASK)&~VMPAGEMASK)
-
-
-extern  jlib_decl IVMAllocator *createVMAllocator(const char *_filename,offset_t size);
-
-
-class  jlib_decl CVMLargeMemoryAllocator: public CLargeMemoryAllocator
-{
-    virtual void allocchunkmem();
-    virtual void disposechunkmem();
-    Linked<IVMAllocator> vm;
-public:
-    CVMLargeMemoryAllocator(
-                          IVMAllocator *vm, 
-                          size32_t _totalmax,
-                          size32_t _chunkmin,
-                          bool _throwexception);
-    virtual ~CVMLargeMemoryAllocator() { reset(); } // call reset before destroyed! 
-    
-};
-
-
-
-#endif

+ 0 - 1
thorlcr/thorutil/thalloc.cpp

@@ -19,7 +19,6 @@
 
 #include "jlib.hpp"
 #include "jlog.hpp"
-#include "jmalloc.hpp"
 #include "jmutex.hpp"
 #include "jcrc.hpp"
 #include "thexception.hpp"

+ 0 - 1
thorlcr/thorutil/thmem.cpp

@@ -21,7 +21,6 @@
 #include "jio.hpp"
 #include "jsort.hpp"
 #include "jsorta.hpp"
-#include "jvmem.hpp"
 #include "jflz.hpp"
 
 #include "thbufdef.hpp"