Questions tagged [memory-management]

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.

Filter by
Sorted by
Tagged with
2 votes
0 answers
35 views

Reusable storage for array of objects V4

Here is a thirdfollow up on Reusable storage for array of objects, Reusable storage for array of objects V2 and Reusable storage for array of objects V3, taking into account the provided answers. The ...
Oersted's user avatar
  • 299
1 vote
1 answer
45 views

Reusable storage for array of objects V3

Here is a second follow up on Reusable storage for array of objects and Reusable storage for array of objects V2, taking into account the provided answers. The following code should be compliant at ...
Oersted's user avatar
  • 299
3 votes
1 answer
48 views

Reusable storage for array of objects V2

Here is a follow up on Reusable storage for array of objects, taking into account the provided answers. The following code should be compliant at least with gcc, <...
Oersted's user avatar
  • 299
4 votes
2 answers
331 views

Reusable storage for array of objects

My goal is to have a memory pool non-template class that is used to store arrays of objects. The same memory pool object must be reusable for a different array (difference size, different type and/or ...
Oersted's user avatar
  • 299
2 votes
1 answer
67 views

Yet another std::unique_ptr implementation

I know I haven't implemented many methods, and haven't specialized it for T[], but I just want to see if what I coded is good or bad. ...
jamesee's user avatar
  • 21
7 votes
2 answers
151 views

shared_ptr implementation code - first cut

I've written an implementation of shared_ptr. It doesn't support weak_ptr (yet) but below is the code. I'd appreciate any feedback, comments. ...
Greg's user avatar
  • 71
6 votes
1 answer
1k views

Simple stack allocator in C

My plan is to allocate a fixed amount of static memory at initialization (a few MBs), and use a stack allocator for quick temporary buffers. The idea is to avoid calls to ...
KTSnowy's user avatar
  • 63
5 votes
2 answers
592 views

Construct mesh from a point cloud

I have been developing a program with C lately, its purpose over the top is to reconstruct meshes from point clouds which are generated by finding the intersection points of numerous rays fired at the ...
Di0n's user avatar
  • 51
-1 votes
1 answer
74 views

Copying allocated data into std::map in a smart way [closed]

I come across a problem and I solved it. The solution works but I have some feelings that there is something wrong with my solution/code. To be clear, let's assume that cars on the race track transmit ...
unique's user avatar
  • 101
3 votes
1 answer
113 views

Doubly-linked list functions

This is my first time implementing a doubly-linked list. I would like some feedback on my code. Any comment would be appreciated regarding the quality of the code, bad implementation, memory ...
Toideki's user avatar
  • 31
6 votes
3 answers
1k views

Implementation of a shared pointer constructors and destructor

I am writing my simple shared pointer. I am asking to review existing functions (understand that my implementations is not full, e.g now operator*) Review please ...
mascai's user avatar
  • 375
6 votes
1 answer
224 views

Doubly linked list first fit free list malloc/free in Python

As an exercise I've implemented malloc and free in Python as a first fit free list as described here. This tracks which blocks are free in a doubly linked list that is sorted by the address of the ...
Xander Dunn's user avatar
0 votes
1 answer
129 views

Multiple containers share a single memory resource

In my project, I'm trying to use the std::pmr allocator and monotonic_buffer_resource. I'm using vector in various classes, and ...
goodman's user avatar
  • 103
1 vote
2 answers
463 views

C Arena (pool allocator)

I wrote a pool allocator (Arena) for a compiler I'm writing. My use case for this allocator is for storing the parse tree because it allows me to free all the memory at once, so I don't need to keep a ...
Itai Nelken's user avatar
10 votes
5 answers
2k views

Implementation of a two-dimensional array in C

I implemented a two-dimensional array in C and would like to know if the implementation is sound in terms of Memory management Potential bugs and other side effects that I missed Code style (...
Gilfoyle's user avatar
  • 1,125
3 votes
2 answers
299 views

Implementation of a market that matches bids to offers

This is my task: Each line in the file can be one of the following: Updates to the limit order book in the following format: ...
Данил Денк's user avatar
5 votes
1 answer
345 views

Simple Memory Arena

A memory arena implementation targeting standard C - this is draft code for Slider 3 (https://mrsename.blogspot.com/), a new programming language implementation being developed. Other memory arena ...
Thisis Afal Sename's user avatar
5 votes
4 answers
812 views

StringPool in C++

I wrote a simple string pool for my compiler in C++ and want to hear your thoughts on its design. String pool has 2 functions: intern and ...
gavrilikhin.d's user avatar
4 votes
1 answer
360 views

Simple slab allocator in C

Here is the plan: a slab takes up 1 page and it has PGSIZE / blocksize amount of blocks the minimum blocksize is 8 bytes, otherwise the pointer to the next block ...
runningupthatroad's user avatar
3 votes
2 answers
136 views

Ray tracer in c running slowly

I was learning C the past few days and decided to make a mini project to get a better feel for it following the Ray Tracing In a Weekend Series. I got it working however I feel like it is pretty slow ...
Aayush's user avatar
  • 61
3 votes
4 answers
897 views

Read arbitrary length strings in C

This is a classic thing to want to do since it's in C that one doesn't have the std::string of C++ and input of Python. I ...
Leonardo Lovera's user avatar
1 vote
1 answer
300 views

Virtual memory manager in C

Virtual Memory manager that has functions, mappage, unmappage, remappage If the physical ...
runningupthatroad's user avatar
3 votes
1 answer
219 views

Bitmap page allocator in C

Bitmap page allocator that scans the bitmap linearly looking for size amount of pages. Everytime it founds a free page, it check if the next ...
runningupthatroad's user avatar
2 votes
1 answer
130 views

Priority Job/Task Queue for Linux (sockets and multithreading)

Preface Please review my implementation of a job queue for linux/unix systems. This is my first time coding in C, although I have quite some experience in C++. I know this is a moderate amount of loc, ...
infinitezero's user avatar
0 votes
1 answer
293 views

Count the number of objects created statically and dynamically in C++

I have written below program to count the number of static and dynamically created object of the class. ...
Naveen Gupta's user avatar
2 votes
0 answers
59 views

Virtual memory manager, physical memory manager and buddy allocator

I'm writing memory manager for my toy operating system and I would like to get some feedback. There is physical memory manager, which uses bitmap, virtual memory manager which uses buddy algorithm for ...
Mateusz's user avatar
  • 21
4 votes
1 answer
612 views

C++ disk-file memory resource

After writing a C++ simulator for malloc() and free(), (C++ imitation of glibc malloc(), free()), I thought: "My simulator ...
frozenca's user avatar
  • 1,683
10 votes
1 answer
219 views

C++ imitation of glibc malloc(), free()

I wrote a C++ simulator that performs algorithms for glibc malloc() and free(). The core logic is basically the same, with the ...
frozenca's user avatar
  • 1,683
1 vote
1 answer
109 views

C++ - Memory allocation utility functions. Is there memory leakage here?

I am quite new at C++ and I really wanna learn how to work with allocating memory. So I have created some utility functions. I am aware that C++ uses new and ...
user260583's user avatar
3 votes
3 answers
158 views

C program that splits the string based on a character

I tried and made a program using my beginner knowledge of C to split a string into multiple sub strings. I just wondered how languages like Python and Javascript implemented the ...
Diwas10's user avatar
  • 111
-3 votes
2 answers
574 views

implementing malloc with mmap

I saw this post. Is this a good implementation of malloc using mmap? memory.hpp ...
Dolev Dublon's user avatar
2 votes
0 answers
198 views

OSDEV Physical Memory Manager (PMM) in C

I ported the Physical Memory Manager from Vinix into C for a little OS I'm working on. I'd love to get some feedback. Here's my code: ...
Rayan's user avatar
  • 21
0 votes
0 answers
68 views

Ewald summation in Julia

I am writing a small MD (molecular dynamics) engine in Julia and I noticed that 67% of the time spent running the following Ewald summation function (to calculate coulomb energy of an infinite crystal ...
poisonDartFrog's user avatar
0 votes
1 answer
39 views

OAuth implementation for Puredata

I am managing an OAuth implementation for Puredata (Pd), which is written in C. OAuth can accept RSA keys, but Pd cannot send messages with newlines, so placing private keys will come as a list of ...
Residuum's user avatar
  • 155
1 vote
2 answers
261 views

Improvement suggestions to my shared_ptr and weak_ptr implementations

Below is the entire code. I appreciate if, someone with more C++ experience can suggest if this can be improved further and if you notice any issues. controlblock.hpp ...
Albin M's user avatar
  • 135
1 vote
1 answer
181 views

C++ intializing and saving mp4 ftyp box struct byte by byte

I'm unsure whether the way I'm performing initialization is recommended, and whether there is a simpler way to save out a struct like the one I'm using. The main points of feedback I'm looking for are ...
Li Brary's user avatar
1 vote
1 answer
300 views

C++ RAII helper classes for malloc arrays and files

I'm going to use these classes in a program I'm working on, so I want to see if they're correct or could be improved. https://pastebin.com/qx7ccteT ...
my_stack_exchange_account's user avatar
2 votes
2 answers
154 views

C library implementing binary trees

This is my first attempt at writing a library in C. I have only included tree creation and in-order traversal function for now, but will expand to have more functions soon. I have three files, ...
Vedant Jadhav's user avatar
3 votes
1 answer
1k views

C++ thread-safe object pool

This is a modern C++ implementation of a thread-safe memory pool -- I want to make sure I am solving the critical section problem correctly (no deadlocks, starvation, bounded waiting) and I am getting ...
wcochran's user avatar
  • 141
6 votes
4 answers
701 views

Simple Singly-Linked List class

Decided to write something simple and came up with idea to write simple single linked list in C++ to improve my knowledge about pointers and memory management in C++, and wrote this: ...
xxnoflz's user avatar
  • 105
4 votes
2 answers
187 views

Linked list implementation for a beginner in C

So I've decided to dabble a bit into C, and while it's trippy as heck I've finished an implementation of a linked list for practice. I've pretty sure there's some type of obscure bug or memory leak in ...
k huang's user avatar
  • 141
3 votes
1 answer
744 views

Setting all class members to null to destroy strong references

At work we are using Xamarin.iOS for our apps. We frequently have to fight it's disadvantages, namely it's memory leak issues where strong cyclic references keep objects alive and prevent them from ...
Frederik Hoeft's user avatar
1 vote
2 answers
358 views

Dynamically allocating a 3D-array in c

I want to use dynamically allocated data, corresponding to a 3D array in a C program. After using the data, I would like to properly deallocate the data again. My approach is as follows: ...
Alf's user avatar
  • 111
2 votes
3 answers
273 views

Fixed-size memory allocator

I've been trying to implement a simple Boost PMR allocator that has a fixed amount of memory. My first implementation (which can be found here) had undefined behavior and did not handle memory ...
Kory's user avatar
  • 31
5 votes
2 answers
684 views

C++ Garbage Collector - Simple Automatic Memory Management

I made a general smart pointer which fixes the problems of loops between std::shared_ptr's. While use is simple, I feel that my code is inefficient and clumsy. Here ...
Captain Hatteras's user avatar
1 vote
2 answers
180 views

Download and unzip an XML document

I am working on an integration software. I will need to download a list of products and import it into my website. The list of products will be downloaded from ...
Hooman Bahreini's user avatar
4 votes
1 answer
652 views

C++ : Allocator for fixed size object

I'm reading "Modern C++ Design" (A. Alexandrescu, 2002). The author said "the standard memory allocator is awful for small objects", but it has been two decades after the book has ...
frozenca's user avatar
  • 1,683
3 votes
2 answers
153 views

Generating prime numbers quickly in rust

I am attempting to re-implement a postponed sieve algorithm for generating prime numbers in Rust. I am able to make a solution that works, but I have to use a couple of ...
kbrose's user avatar
  • 151
6 votes
3 answers
2k views

Dynamic array implementation using C++

I implemented a basic dynamic array using C++. When deleting an element and shifting the others, the last element will be twice repeated (the original still exists after copying). I want to avoid ...
Youssef Refaat's user avatar
7 votes
2 answers
672 views

2D Maze Game with Monsters

Introduction I've started to learn C programming a bit and wanted to create a simple 2D console game. Let me first introduce you to the game level/map structure: ...
never_feel_mellow's user avatar

1
2 3 4 5
13