dlmalloc | C version of Doug Lea 's excellent malloc implementation

 by   greg7mdp C++ Version: Current License: No License

kandi X-RAY | dlmalloc Summary

kandi X-RAY | dlmalloc Summary

dlmalloc is a C++ library. dlmalloc has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.

A C++ version of Doug Lea's excellent malloc() implementation. I have been having issues with the malloc() implementation on Windows, where the memory usage can grow unreasonably large with some patterns of successive reallocations. So I decided to investigate Doug Lea's malloc implementation. It is very easy to use, a single C file that you just compile and link along with your source code, and you are all set. Using Doug's malloc.c worked beautifully. For my use case, it was faster than Windows default malloc (I'm using Visual C++ 2015), and the memory usage was considerably reduced. I wanted to understand the code, as I would like to use its core logic to make a custom C++ allocator for my sparse hash table. However, I found the source code very difficult to follow. A lot of it is implemented with preprocessor macros, and is invisible to debuggers. Macros are of course necessary when coding in C for ultimate performance, but they sure obfuscate the code. Also, I'd like my C++ allocator to be header only, but shoving all these macro definitions into a header file would pollute the global name space, which is not acceptable. Therefore I decided to convert Doug's original malloc.c (v2.8.6) to C++, and this is what you find here. I have not modified what the code does, just how it is specified and organized (modulo any typo or bug I may have introduced of course). Interestingly, the C++ version is just as fast as the original C version! In my tests (Visual C++ 2015, Windows 10), the C++ version was even very slightly faster. While Linus may be opposed to C++, I still though that sharing this C++ implementation could be useful for people who, like me, would like to examine the inner workings of one of the best malloc implementation ever written.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              dlmalloc has a low active ecosystem.
              It has 116 star(s) with 10 fork(s). There are 8 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 0 open issues and 1 have been closed. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of dlmalloc is current.

            kandi-Quality Quality

              dlmalloc has 0 bugs and 0 code smells.

            kandi-Security Security

              dlmalloc has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              dlmalloc code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              dlmalloc does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              dlmalloc releases are not available. You will need to build from source code and install.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of dlmalloc
            Get all kandi verified functions for this library.

            dlmalloc Key Features

            No Key Features are available at this moment for dlmalloc.

            dlmalloc Examples and Code Snippets

            No Code Snippets are available at this moment for dlmalloc.

            Community Discussions

            QUESTION

            Rust WebAssembly Custom Elements Memory Deallocation Error
            Asked 2019-Apr-19 at 15:13

            My first Rust-produced WASM is producing the following error, I have no idea how to go about it debugging.

            ...

            ANSWER

            Answered 2019-Apr-19 at 15:12

            Your problem is that you create a chunk of uninitialized memory and don't initialize it properly:

            Source https://stackoverflow.com/questions/55741517

            QUESTION

            How does dlmalloc coalesce chunks?
            Asked 2017-Jun-04 at 18:30

            Here is a detailed description of the dlmalloc algorithm: http://g.oswego.edu/dl/html/malloc.html

            A dlmalloc chunk is bookended by some metadata, which includes information about the amount of space in the chunk. Two contiguous free chunks might look like

            ...

            ANSWER

            Answered 2017-Jun-04 at 18:30

            You can see the answer yourself by looking at the source. Begin with line 1876 to verify your diagram. The metadata is just two size_t unsigned integers, accessed by aliasing a struct malloc_chunk (line 1847). Field prev_size is the size of the previous chunk, and size is the size of this one. Both include the size of the struct malloc_chunk itself. This will be 8 or 16 bytes on nearly all machines depending on whether the code is compiled for 32- or 64-bit addressing.

            The "normal case" coalescing code starts at line 3766. You can see that the size variable it's using to track coalescing is chunk size.

            So - yeah - in the code blocks marked /* consolidate backward */ and /* consolidate forward */, when he adds the size of the preceding and succeeding chunks, he's implicitly adding the size of the struct malloc_chunk as you suspected.

            This shows that your interpretation is correct. My expectation is that the textbook author just got sloppy about the difference between chunk size (which includes metadata) and the size of the memory block allocated to the user. Incidentally, malloc takes care of this difference at line 3397.

            Perhaps the bigger lesson here is that - when you're trying to learn anything - you should never skip an opportunity to go straight to the first-hand source and figure stuff out for yourself.

            Source https://stackoverflow.com/questions/44213973

            QUESTION

            Crash at sws_scale when converting AVFrame to RGB32
            Asked 2017-Mar-01 at 19:17

            Crashing at sws_scale when converting an AVPicture

            At first I was using sws_scale to actually scale the frames up but the cpu overhead was too high, so I decided to just convert the frames and adjust the QImage size instead. Before it was working and I was getting the video displaying when rendered, but now it crashes at sws_scale.

            This is written in Qt for Android and using FFMpeg 3.1.4.

            Also, is there another way around not using the deprecated functions?

            Does anybody know why I am getting the crash at sws_scale?

            The class for the VideoFrameCopy

            ...

            ANSWER

            Answered 2017-Mar-01 at 19:17

            Regarding the crash: it would be helpful to understand whether access violation was related to reading input picture or writing output picture. Anyway, so far I can see only one issue with the code: you cannot use av_image_fill_linesizes when using QImage as a target. Linesizes must match actual image layout (just like data pointers must match actual image position in memory) so use something like this:

            Source https://stackoverflow.com/questions/42504164

            QUESTION

            mbed client build error
            Asked 2017-Feb-20 at 12:18

            I am trying to compile the mbed client example on a windows machine for the K64F board. I have installed all the required software as described in the guide https://github.com/ARMmbed/mbed-client-quickstart.

            The commands I have run are the following commands:

            ...

            ANSWER

            Answered 2017-Feb-20 at 12:18

            That's the old example code based on mbed OS 3. Use the example for mbed OS 5 instead.

            Source https://stackoverflow.com/questions/42297012

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install dlmalloc

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/greg7mdp/dlmalloc.git

          • CLI

            gh repo clone greg7mdp/dlmalloc

          • sshUrl

            git@github.com:greg7mdp/dlmalloc.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link