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
1 vote
2 answers
201 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
746 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,693
3 votes
2 answers
169 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
723 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
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, ...
WuselDusel's user avatar
7 votes
2 answers
1k 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 ...
Henry Cooper's user avatar
0 votes
1 answer
590 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 ...
Payal's user avatar
  • 3
4 votes
3 answers
554 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 ...
cid's 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 ...
toni's user avatar
  • 61
4 votes
1 answer
396 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 ...
Someone's user avatar
  • 161
0 votes
1 answer
42 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 ...
JimmyHu's user avatar
  • 3,974
1 vote
0 answers
29 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 ...
Michael's user avatar
  • 11
5 votes
2 answers
328 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 ...
JimmyHu's user avatar
  • 3,974
0 votes
1 answer
459 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 ...
Sharki's user avatar
  • 189
6 votes
4 answers
1k 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: <...
tommsch's user avatar
  • 243
3 votes
3 answers
2k 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 ...
JimmyHu's user avatar
  • 3,974
4 votes
4 answers
944 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 ...
JimmyHu's user avatar
  • 3,974
1 vote
2 answers
741 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 ...
debdutdeb's user avatar
2 votes
0 answers
35 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 ...
bro's user avatar
  • 21
2 votes
1 answer
558 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, ...
Serkan Gün's user avatar
2 votes
0 answers
90 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 ...
Šimon Gido's user avatar
0 votes
2 answers
130 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 ...
cynnad's user avatar
  • 79
2 votes
1 answer
400 views

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

...
Symlink's user avatar
  • 143
4 votes
2 answers
157 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
489 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 ...
Barnack's user avatar
  • 207
1 vote
1 answer
532 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 ...
TheDcoder's user avatar
  • 135
1 vote
2 answers
581 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 ...
Dagar's user avatar
  • 413
3 votes
1 answer
133 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): ...
cynnad's user avatar
  • 79
2 votes
2 answers
202 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. ...
Ricardo Silva's user avatar
11 votes
4 answers
4k 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 ...
ethan warco's user avatar
0 votes
1 answer
497 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 ...
PeePeePooPoo's user avatar
0 votes
0 answers
135 views

creating worksheets for unique values parsed

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 ...
Quentin's user avatar
4 votes
1 answer
129 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 ...
sdasdadas's user avatar
  • 557
1 vote
1 answer
142 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 ...
Ivan Shelomentsev's user avatar
9 votes
3 answers
5k views

A Tic Tac Toe game in C++

I am a beginner programmer and have made a tic tac toe program in c++. I need some help with my memory management can anyone review and help me. This is my code ...
Vedant Matanhelia's user avatar
3 votes
1 answer
390 views

Maintain a list of contacts in C

I have a function that gets a string and prints it as a message. Then, it reads the text from stdin, saves it in a pointer and sends it back: ...
RedYoel's user avatar
  • 301
8 votes
1 answer
2k views

Fast Native Memory Manipulation in VBA

I've been quite annoyed lately by the fact that the CopyMemory API (RtlMoveMemory on Windows and ...
Cristian Buse's user avatar
4 votes
1 answer
110 views

Matrix template Class

This is my 2nd shot at dynamic memory allocation. This project is for practice purposes. So many things were considered whilst writing this minimal project. I considered using placement new to ...
theProgrammer's user avatar
2 votes
3 answers
87 views

Copy file using read and write streams

I have this piece of code in my program, where I assign 10000 as the size of the buffer. Now How can I check if the file that I am copying is less than 10000, for example 5000, than how to free the ...
Jopan's user avatar
  • 23
0 votes
1 answer
94 views

Simple C++ Dynamicly allocated Matrix with only one memory allocation [closed]

I was bothered with existing matrix allocation methods that take variable rows and columns, so I made a small class that only needs one memory allocation. ...
Eduardo Andrés Castillo Perera's user avatar
3 votes
1 answer
1k views

A custom memory allocator in c++

Recently I became interested in implementing a FORTH language interpreter. That led me to read about memory models etc. which led me to write this custom memory allocator in c++. It's very dumb as ...
Jaldhar's user avatar
  • 409
5 votes
3 answers
117 views

Removing unneeded objects from an array before rendering

I'm making a function that adds a new object to an array and removes the oldest if it has reached a specific length. Click the button in the example below. All objects are drawn until its array ...
Will Pierce's user avatar
4 votes
1 answer
590 views

slab malloc/free implementation

I'm trying to implment memory allocator guided by this tutorial. I used a mix of Next-fit search and Segregated-list search. There are multiple slabs of different sizes (a slab is contagious blocks of ...
0xDEADC0DE's user avatar
1 vote
2 answers
180 views

Better way to calculate double-scattering diffraction using cartesian product of arrays?

This script calculates points in reciprocal space for hexagonal 2D lattices, then uses the cartesian product from itertools to add each vector from one lattice to all of the vectors of the other in ...
uhoh's user avatar
  • 451
11 votes
1 answer
1k views

Customization of memory class C++

I have implemented a customized memory allocation class template for an assignment. Codes are commented; Hopefully it's clear. I would love to know if there is any way to make the code more optimized. ...
starrk's user avatar
  • 369
3 votes
1 answer
99 views

Workbook _open copy-paste reference sheet (30k+lines) from other workbook on change only

Working on finding a way to reduce in-cell formula size and memory usage of my excel workbook, i came up with the idea to "load" (copi-paste) the reference sheet i was mentioning a lot with ...
Patates Pilées's user avatar
6 votes
0 answers
86 views

Subtracting elements of datasets of an HDF5 file

I am trying to solve the following problem: Input: Input is two arrays (Nx4, sorted in column-2) stored in datasets-1 and 2 in HDF5 file (input.h5). N is huge (...
nuki's user avatar
  • 61
2 votes
1 answer
52 views

Proper way of deallocating memory in SLL?

So I'm making my own singly linked list class, with methods that you'd expect such as remove() and insert(). I don't use ...
Alex's user avatar
  • 217
4 votes
1 answer
201 views

C++ Dynamic Array Class Testing

I'm creating a basic Dynamic Array class in C++, and I'd like to know if there are any bugs/memory leaks I haven't noticed yet. dyn_arr.h : ...
DarkoNaito_09's user avatar

1
2
3 4 5
13