Memory management is the act of managing computer memory by allocating portions of memory to programs as well as freeing memory so that it can be re-used.
2
votes
1answer
46 views
Simple class to mimic a dynamic array
for my c++ class I was asked to write a class with the following characteristics:
Implement a vector replacement that operates only on integers (you don't need to use templates like the normal STL)...
2
votes
1answer
43 views
Templated double ended queue (deque) move semantics edge cases C++
My original deque implementation and efficiency question lacked move semantics. After ratchet freak provided an example of how to define them I decided to try adding them to my deque. The unit test + ...
4
votes
1answer
69 views
Template double ended queue (deque) implementation using dynamic allocation C++
I have written my own deque class to get a better grasp of C++ pointers and memory management. The following code is part of a larger 2D isometric game I am developing. It compiles and runs fine using ...
6
votes
1answer
98 views
Reference Counting in C99
(I created a GitHub repository; there are few improvements as suggested by other users in the comments)
As we know, C99 has no garbage collector. To address the problem of manually deallocate objects ...
1
vote
2answers
93 views
Perlin Noise Generator
I'm porting a 2-D Terrain Generator from Python to C++ as Python is too slow due to the number of features that have been added.
I'm new to C++ and would like to know of any criticisms that you can ...
3
votes
0answers
20 views
Extending Array to make a stack that bubbles unused objects up and active object down
Array.prototype.fastStack
To combat GC and its impact on animation I created Array.fastStack that adds to the array prototype.
It's a sort of stack that bubbles ...
2
votes
1answer
45 views
Dynamic Array Bags
For one of my assignments, we were asked to create a data structure similar to Bags using dynamic arrays where the order would be important - which I was able to do successfully, that is, the code ...
3
votes
1answer
40 views
Basic memory pool, alignment, thread safety
Mainly for practicing purposes, I'm trying to implement a simple, yet efficient memory pool. It's basically a linked list that is able to grow, with fixed sized members. Each node has a flag if it's ...
1
vote
1answer
39 views
Simple but (hopefully) safe C nodes for data structures
Nodes will be for simply linked lists, circular lists, maybe later on extending them to work with graphs. I'm trying to be as defensive as possible, will this leak memory? It runs perfectly I'm just ...
6
votes
0answers
124 views
A vector-like polymorphic container to store objects from a type hierarchy in contiguous memory
Normally, in order to have a polymorphic collection, we store pointers to a base class:
...
3
votes
1answer
39 views
Memory allocation tracking using anonymous lambda wrapper
I had this idea to exploit anonymous lambdas that are immediately executed that wrap around an allocation function to track those allocations in a statically created Stats object.
This is the code I ...
2
votes
1answer
76 views
Ensure that ICommand implementation properly uses weak references
I am building an implementation of System.Windows.Input.ICommand that is like the commonly used RelayCommand, but doesn't keep a ...
0
votes
0answers
22 views
Helper class for accessing blobs and mmap memory - follow up
This class was inspired from Microsoft's array_view.
It intended to use with mmap-ed memory for easily check bounds and so on.
I probably will need to throw exceptions, but this is not my usual way ...
2
votes
1answer
41 views
Helper class for accessing blobs and mmap memory
This class was inspired from Microsoft's array_view.
It intended to use with mmap-ed memory for easily check bounds and so on.
...
0
votes
2answers
65 views
Code for calculating number of trailing zeroes after factorial
While trying my hands at the beginner codechef problem I came across this . So basically doing that problem with Dynamic programming is an overkill but why not try that and get some DP practice.
Nice,...
6
votes
2answers
69 views
ObservingCache - scheduled task executor that returns a result
I wrote a utility class called ObservingCache, which receives a task in the form of Supplier<T> and an interval, computes the task every [interval] millis and ...
4
votes
2answers
67 views
A dynamic memory resource with alignment support
Although C11 introduced aligned_alloc( alignment, size ), there is no support for aligned reallocation (AFAIK). The ...
4
votes
2answers
80 views
Simple program to read memory usage by PID in Linux
I just learn a little bit about C Programming and try to create a modular program so I created simple program to read memory usage by pid(s) in Linux.
...
1
vote
1answer
188 views
Brute-force password cracker
I am trying to write a program to find a zip file's password. I know the password consists of only lower-case letters and it's length does not exceed 6 characters. I wanted to check the passwords of ...
0
votes
1answer
33 views
Split a file into individually allocated lines
This is part of a larger project that is to run on POSIX systems. My concerns with it are the lack of comments, best practices with the filesystem, and naming things. Of course all feedback is great.
...
3
votes
0answers
29 views
Round-tripping from LinkedHashMaps to Clojure collections
I'm trying to implement round-tripping from LinkedHashMaps to Clojure collections. The implementation below works for smaller collections, but larger collections raise ...
10
votes
3answers
214 views
Structure to ByteArray Extension
I have a need to turn various structures into byte arrays to be sent over serial port to another machine. I created generic extensions to turn any structure into a byte array and from a byte array ...
11
votes
2answers
2k views
Taking arbitrary length input in C
Instead of having to use something like char buf[100500] and hope that no possible user input could be longer than 100500 bytes, I decided to make the following ...
4
votes
0answers
47 views
cross-platform stdlib-only aligned allocator in C++14
I'm writing a program which uses OpenCL, and the OpenCL types are mostly over-aligned. Sometimes when using stl containers with these types, I'd get segfaults, so I tried to write my own aligned ...
5
votes
2answers
82 views
NamedPoint class using unique_ptr for members
After reading this old article from 2001 I have tried to implement the class from it using unique_pointer.
An author's claim is that C++ is not appropriate for ...
4
votes
1answer
139 views
New malloc implementation
I've written a new malloc implementation similar to dlmalloc and was hoping for feedback on it.
The goals for this library are:
...
0
votes
1answer
64 views
Serial communuication application of 24*7 having memory issue
I am having a serial port communication application using 3 serial ports DMX (m_port,m_port1,m_port2) which will run 24 *7 , so i just need to ensure memory usage doesn't go above limit with using(), ...
8
votes
5answers
373 views
Custom list to avoid out of memory exceptions
The following class is a helper to avoid OutOfMemoryException exceptions being thrown when the list is to large so that it is added onto the large objects heap. To ...
8
votes
0answers
161 views
Aligning your heterogenous uninitialized memory to make the processor happy
After learning more about memory alignment and how it can impact processor data access, I tried to find something in the standard that offers proper memory alignment inside blocks of raw memory that ...
2
votes
0answers
76 views
Low performance of HTTP request using Haskell wreq
The program makes HTTP requests (checks video stream status) and calls an external program.
...
4
votes
2answers
149 views
C++ object pool
I am a beginner and would like to build a pool. I made some research and found out that if my software has heavy object create and delete part, I should use a pool because of performance. I made some ...
2
votes
1answer
91 views
Pointer lists for a C++ garbage collector
The problem
My intention is to have a class A and class B. class B has a ...
10
votes
1answer
72 views
Longest lines using priority queue
Inspired by a comment on this question, I thought I'd exercise my C skills by implementing something like it using a priority queue.
The idea is to be able to invoke the program like this:
./...
4
votes
1answer
63 views
Allocating a contiguous block of memory for an array
I try to work with a contiguous block of memory, to create an array (2D) whose SIZE is not known at compile time (before c99) so no variable-length arrays are involved here.
I came up with the ...
3
votes
1answer
58 views
Testing different implementations of malloc()
Can you help me verify my test result? I'm testing different malloc() implementations with a small program that allocates gigabytes many times:
...
3
votes
2answers
110 views
calloc, malloc, free and realloc wrappers to store the size being allocated
I'm currently building a node.js addon for libcurl. Right now I'm trying to correctly use v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory to ...
0
votes
0answers
82 views
Fast ReadProcessMemory, save guest names that is in memory in hum text file
My code is very slow. How do I get it fast? I would also like to put a scanner on if you have a name in memory to save it in a text file.
...
-4
votes
2answers
164 views
RAM overhead on a compression program [closed]
In a program, the one below is attempting to codify into a translation of another file. The output is severely condensed. It works, and once I get it to decompress, then it will win award after award. ...
4
votes
3answers
253 views
Simple Pool Allocator
This is a simple pool allocator, based (to at least some degree) on a previous answer. The basic idea is pretty simple: allow a user to allocate objects of some type quickly (in relatively large ...
5
votes
1answer
108 views
Lazy String splitter in C++
I created a string splitter in C++. It splits a string in a lazy fashion and makes use of forward iterators to sequentially supply the next token from the string until it runs out of tokens.
...
6
votes
2answers
79 views
Comparing vehicle crash data the previous year
I have created an automated macro which takes vehicle crash data from a .csv file and automatically creates a pivot table and charts and compares it to the previous year. The code is approximately ...
10
votes
1answer
80 views
Block allocator
I wrote this block allocator for exercise and would love to get your reviews.
Main features I wanted to have:
Detecting buffer overflows with canary terminator.
Being able to allocate arbitrary ...
2
votes
0answers
56 views
Fetching a weather report on an Arduino from a web service
I'm writing some code which is basically supposed to http get some information from my own website and parse it, which (finally) works. However, when I compile the code, it shows this:
Sketch uses ...
6
votes
3answers
132 views
View programming pattern in C++ without raw pointers
I'm trying to achieve, for lack of a better term, a "view" pattern in C++. It's probably most comparable to "views" in the Database world, where one can make a query, and then perhaps aggregate the ...
3
votes
0answers
21 views
Using STORAGE macro using QSAM for input/output
I was wondering if you can help me out. I wanted to know if there is an easier way to do the following. My code works but I feel like there is a lot things going out with multiple loops and wanted to ...
1
vote
0answers
48 views
Producer/Consumer write to file
I'm concerned with the memory usage of this application. When I start it and look at it's memory usage while it's waiting for input, it's memory usage is around 13,212 K.
When the application runs ...
4
votes
2answers
205 views
Memory Management Code
For a project I had to do a memory management problem without creating any custom classes or templates using the provided pool array and ...
1
vote
2answers
104 views
Delphi 2009 interface
I have this code and at the end of it, FastMM shows that there were memory leaks with all the objects of TSinc:
...
4
votes
2answers
816 views
Binary file validity in C++/C++11: checking a binary header
I have some code for checking a binary header to see if a binary file is meant to be read by a certain program, and I could use some extra eyes to review it.
Assume the following ...
8
votes
1answer
112 views