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
-3 votes
2 answers
111 views

implementing malloc with mmap

I saw this post. Is this a good implementation of malloc using mmap? memory.hpp ...
user avatar
2 votes
0 answers
40 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: ...
user avatar
  • 21
0 votes
0 answers
31 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 ...
user avatar
0 votes
1 answer
30 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 ...
user avatar
  • 155
1 vote
2 answers
140 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 ...
user avatar
  • 135
1 vote
1 answer
51 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 ...
user avatar
1 vote
1 answer
137 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 ...
user avatar
2 votes
2 answers
53 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, ...
user avatar
3 votes
1 answer
188 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 ...
user avatar
  • 131
6 votes
4 answers
654 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: ...
user avatar
  • 105
4 votes
2 answers
76 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 ...
user avatar
  • 41
3 votes
1 answer
137 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 ...
user avatar
1 vote
2 answers
65 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: ...
user avatar
  • 111
2 votes
3 answers
141 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 ...
user avatar
  • 31
5 votes
2 answers
553 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 ...
user avatar
1 vote
2 answers
76 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 ...
user avatar
4 votes
1 answer
193 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 ...
user avatar
  • 1,189
3 votes
2 answers
78 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 ...
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 ...
user avatar
7 votes
2 answers
253 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: ...
user avatar
4 votes
2 answers
1k views

CSV file reader

Hi, I asked this question over on stack overflow. However, they closed the thread and suggested to ask it on code review. So here I am :) The code below is an updated version of my original code, ...
user avatar
7 votes
2 answers
669 views

Hack machine language assembler as required for project 6 of Nand2Tetris

This is the implementation of the Assembler required to parse source code written in the Hack Machine Language and output it to a 16-bit binary file. After writing one go in Swift, I decided I wanted ...
user avatar
0 votes
1 answer
107 views

Writing a buffer that takes a header and a variable number of packets and makes a payload [closed]

I'm writing this as an exercise. I would probably use a vector as a buffer internally (the extra capacity pointer overhead is not important enough). Primarily it's an exercise in writing copy/move ...
user avatar
  • 3
4 votes
3 answers
275 views

Implement IDisposable correctly using object composition principle

Update at the end Is it possible to implement IDisposable pattern correctly while using object composition principle to promote code-reuse, reduce code duplication ...
user avatar
  • 93
5 votes
6 answers
2k views

Implementation of itoa which allocates the string

This is my implementation of itoa() (Integer to Alpha), which converts an integer to a string. Memory management and optimization is important. The caller is not ...
user avatar
  • 61
4 votes
1 answer
138 views

Rust Persistent Red Black Tree Implementation

Below is my implementation of a persistent red black tree in Rust. I have a few questions about potential improvements. Currently the data and nodes are stored in referenced counted pointers. Is this ...
user avatar
  • 161
0 votes
1 answer
37 views

SubImage function implementation in C

This is a follow-up question for Two dimensional gaussian image generator in C, Two dimensional bicubic interpolation implementation in C and A SubPlane Method for Generic Two Dimensional Data Plane ...
user avatar
  • 3,556
1 vote
0 answers
22 views

Inserting captions under photographs in word based on entries in excel spreadsheet

I have a macro written in word for transferring captions written in excel to a corresponding photograph in a word document. At the moment it runs however I am finding that it slows down over time the ...
user avatar
  • 11
5 votes
2 answers
124 views

Two dimensional gaussian image generator in C

This is a follow-up question for Image Processing Median Filter in C. I am attempting to create a two dimensional gaussian image like below in C. The formula is as follows. The experimental ...
user avatar
  • 3,556
0 votes
1 answer
119 views

Getting address with MemorySharp

I'm using MemorySharp to calculate the memory address from a pointer address and then inject values in memory. The code works perfectly, but I was wondering if this would be the right way. I found a ...
user avatar
  • 189
6 votes
4 answers
529 views

Packing and unpacking values in a buffer

I have to deal with raw memory manipulation. For that I wrote a function which stores data one after another, and another function which reads this data and stores it into variables. More precisely: <...
user avatar
  • 225
3 votes
3 answers
449 views

Image Processing Sobel Edge Detection in C

This is a follow-up question for Image Processing Median Filter in C. Under the same tiny bmp image read / write framework, a sobel edge detection function has been performed. The experimental ...
user avatar
  • 3,556
4 votes
4 answers
319 views

Image Processing Median Filter in C

I am attempting to perform Median Filter with size 3 x 3 in C language. The function MedianFilter33 has been implemented as follows. The experimental implementation ...
user avatar
  • 3,556
1 vote
2 answers
235 views

A [non-destructive] better (not really) `strtok` function

The first time I used strtok, it felt, well, weird. But after a while, I became quite used to it. In a way it was simple. Soon after reading a bunch of Stack ...
user avatar
2 votes
0 answers
33 views

Fit memory allocation [duplicate]

The program will read size of free memory partitions and size of processes from a text file and then will try to allocate a memory partition for each process using the first-fit algorithm. Input ...
user avatar
  • 21
2 votes
1 answer
219 views

Contiguous memory allocation using first-fit algorithm

This project I'm dealing with will read the size of free memory segments and size of processes from a text file and then will try to allocate a memory partition for each process using the first-fit, ...
user avatar
2 votes
0 answers
54 views

Dynamic heterogeneous container

I want to have dynamic continuous block of memory for different types, that inherit from single base class. I've written structure for that purpose. I know I play with a fire here, but I would like to ...
user avatar
0 votes
2 answers
109 views

Fixed memory manager in C

I decided to not use heap in my program and create a custom memory manager to retrieve memory chunks from a big global array of uint8_t(u8). I chose u8 since 8 bits is a byte. The very big ...
user avatar
  • 79
2 votes
1 answer
200 views

C++ object pool that returns a smart pointer on request

...
user avatar
  • 143
2 votes
2 answers
132 views

My own function for copying memory in C

I have written a function that copies memory from one destination to another. I would like you to view my code and tell me if I have to fix something. That's the code: ...
user avatar
4 votes
2 answers
368 views

"observer pointer" meant to stay updated when the pointed object is moved in memory

I wasn't sure about how to name it, maybe "follow_ptr", "self_updating_ptr", or "stalking_ptr" or something on those lines. For now it's called Identifier. What I'm ...
user avatar
  • 207
1 vote
1 answer
211 views

dynarr - yet another simple C dynamic array library

I wrote my own dynamic array library for C as I was not happy with the others I found. It is very crude but the basic logic should be correct, it mainly revolves making ...
user avatar
  • 135
1 vote
2 answers
350 views

C ArrayList implementation

I have written a ArrayList class in C and I just wanted some criticism on what I can improve on. Any criticism helps, and I was wondering if there is any better way of doing error handling other than ...
user avatar
  • 403
3 votes
1 answer
99 views

Smart/Dynamic array in C

I attempted to make a smart/dynamic array implementation in C which is supposed to be a hybrid between a C++ vector/stack/queue. This is what i came up with: Header (smart_array.h): ...
user avatar
  • 79
2 votes
2 answers
121 views

Reference-counted smart pointer in C

About I've been experimenting with gcc's __cleanup__ attribute, and thought it'd be a great fit for a memory-safe smart pointer for C. This is the implementation. ...
user avatar
11 votes
4 answers
3k views

C++ dynamic array implementation

As a C++ beginner coming from Java, I have become increasingly confused on the topic of memory management and how to avoid memory leaks. Is the code below risking a memory leak that I'm not currently ...
user avatar
0 votes
1 answer
291 views

Vector Implementation C++ using RAII

I have attempted to implement a similar version of the STL Vector; several functions are missing but I'd like a few words of advice on whether I am indeed on the right track or whether I should change ...
user avatar
0 votes
0 answers
115 views

Performance issue “not enough memory” Macro vba Excel - Parsing data

I have built some code that should parse the data according to a unique value and then create a new Worksheet for each unique value. My initial table has 10 Columns and around 25K rows. The code works ...
user avatar
4 votes
1 answer
81 views

Bump Allocator in Linked List

Here is my code for implementing a linked list with custom allocators (the standard malloc/free and a simple bump allocator). I appreciate any comments or critiques about architecture, formatting, and ...
user avatar
  • 557
1 vote
1 answer
122 views

Reverse Root Solution

Solved one of the easiest problems from acm.timus.ru. 1001. Reverse Root The input stream contains a set of integer numbers Aᵢ (0 ≤ Aᵢ ≤ 10¹⁸). The numbers are separated by any number of spaces and ...
user avatar

1
2 3 4 5
13