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
2answers
103 views
+50

Implement IDisposable correctly using object composition principle

Is it possible to implement IDisposable pattern correctly while using object composition principle to promote code-reuse, reduce code duplication and hide verbose &...
5
votes
6answers
1k 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 ...
4
votes
1answer
65 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 ...
0
votes
1answer
32 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 ...
1
vote
0answers
17 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 ...
4
votes
2answers
79 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 ...
0
votes
1answer
67 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 ...
6
votes
4answers
220 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: <...
3
votes
3answers
77 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 ...
4
votes
4answers
100 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 ...
1
vote
2answers
42 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 ...
2
votes
0answers
31 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 ...
2
votes
1answer
70 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, ...
2
votes
0answers
39 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 ...
0
votes
2answers
105 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 ...
2
votes
1answer
75 views
2
votes
2answers
121 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: ...
4
votes
2answers
309 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 ...
1
vote
1answer
41 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 ...
1
vote
2answers
105 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 ...
3
votes
1answer
86 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): ...
2
votes
2answers
90 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. ...
12
votes
4answers
2k 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 ...
1
vote
1answer
148 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 ...
0
votes
0answers
80 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 ...
4
votes
1answer
68 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 ...
1
vote
1answer
104 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 ...
10
votes
3answers
3k 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 ...
3
votes
1answer
264 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: ...
5
votes
0answers
314 views

Fast Native Memory Manipulation in VBA

I've been quite annoyed lately by the fact that the CopyMemory API (RtlMoveMemory on Windows and ...
5
votes
1answer
76 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 ...
2
votes
3answers
78 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 ...
1
vote
1answer
83 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. ...
2
votes
1answer
272 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 ...
5
votes
3answers
99 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 ...
4
votes
1answer
134 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 ...
1
vote
2answers
109 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 ...
11
votes
1answer
940 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. ...
3
votes
1answer
82 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 ...
6
votes
0answers
47 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 (...
2
votes
1answer
48 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 ...
4
votes
1answer
86 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 : ...
1
vote
1answer
102 views

A Pool-based Memory Management

I wrote a memory management class that is supposed to be used in a game. I decided to use "Blocks" as an in-code representation. It is written in MSVC++ and is currently not meant for ...
4
votes
0answers
153 views

3D Direct Convolution Implementation in C

For my project, I've written a naive C implementation of Direct3D convolution with periodic padding on the input. Unfortunately, since I'm new to C, the performance isn't so good. By convention, all ...
4
votes
2answers
1k views

Malloc and free

I'm looking for help speeding up some code I'm tinkering with. The rest of the code, as well as my 'benchmark', can be found here. ...
4
votes
1answer
73 views

protein sequence translator using basic text manipulation

As an old COBOL coder, all this OOP stuff is foriegn. Would someone please take a look at this program? I'm looking for suggestions for ways to improve this program. While it works, I'm sure there's ...
2
votes
1answer
66 views

c++ new-handler

I had just put together my first public project: simple(sane) new-handler for c++. It allocates some reserved memory on start up, then releases it piece by piece. It may also raise a signal when each ...
3
votes
2answers
77 views

String input and split functions in C

I've some functions targeted to simplify working with strings in some of my other projects. I'd like feedback on this code and whether or not the implementation is efficient and memory safe. I work ...
3
votes
0answers
42 views

Custom allocator for improved cache locality and fast iteration in C++

I am writing a custom allocator for my educational game engine project where I need to iterate through a collection of components(similar to Unity3D) every frame. There are game objects and every game ...
3
votes
1answer
114 views

dumb::vector - a class for students to use when they are expressly forbidden from using std::vector

I have created a small library for use by beginner C++ students who are forbidden from using std::vector in their projects. Because of this, I would like you to ...

1
2 3 4 5
12