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

Unmanaged byte array to managed structure

I have a need to turn byte arrays into various structures. First version: ...
David Michaeli's user avatar
7 votes
3 answers
4k views

malloc in main() or malloc in another function: allocating memory for a struct and its members

When initializing a struct in C, we can allocate memory inside the main function or within another function and return a pointer to the newly created struct. This ...
David's user avatar
  • 181
7 votes
1 answer
1k views

A C++17 `std::allocator` implementation

This is an implementation of C++17 std::allocator under the name my_std::allocator, with deprecated stuff omitted for simplicity....
L. F.'s user avatar
  • 9,456
4 votes
0 answers
1k views

C++ shared_ptr memory pool

I put together this little memory pool class to help avoid the costs associated with heap allocation and deallocation of objects that are frequently created & destroyed. It creates C++ standard <...
Thomas Johnson's user avatar
5 votes
1 answer
151 views

A custom, highly-specialized, special-purpose standard-compliant C++ allocator

Brief Preface I recognize that there are many nuances and requirements for a standard-compatible allocator. There are a number of questions here covering a range of topics associated with allocators....
Shmuel Levine's user avatar
2 votes
1 answer
200 views

Wipe sensitive information from memory in Python

I have come up with the following method to remove sensitive information with the help of the garbage collector: ...
volingas's user avatar
  • 121
1 vote
0 answers
23 views

Initializing and managing many references in multithreaded control application

I have a large multi-window GUI program (implemented with MFC) that controls a variety of physics experiment apparatus. When the user starts the main function of the program (the "experiment" run), a ...
aquirdturtle's user avatar
2 votes
1 answer
54 views

Constructor for a packagetarget struct

As many of you know goto is usually signs of code smell. However I thought this could be an appropriate case, and would like confirmation or criticism. Unnecessary ...
utkumaden's user avatar
2 votes
1 answer
172 views

Generate alternate saturday dates list within range in R

...
Stupid_Intern's user avatar
1 vote
1 answer
37 views

Dynamically-resizable array implementation, for use in a game-dev-related library

I've been working on a library that includes a list-like structure, which I use internally multiple times to store different types of structs. However, I'm not entirely confident with my ability to ...
Ethan McTague's user avatar
5 votes
2 answers
1k views

Implementation of memset_s based on C11 standard

The following code attempts to implement memset_s() based on section K.3.7.4.1 of the ISO/IEC 9899:201x N1570 draft: ...
Tanveer Salim's user avatar
-1 votes
1 answer
63 views

Write/read efficiently dataframe objects into memory or disk [closed]

i'm running a for loop that loops over all the rows of a pandas dataframe, then it calculates the euclidean distance from one point at a time to all the other points in the dataframe, then it pass the ...
Miguel 2488's user avatar
2 votes
0 answers
49 views

Fixed Size Resource Array with Versioned Indexes

I'm trying to implement a fixed sized array that uses versioned keys for dangling safety. This structure is similar to a slot map data structure, with the exception that this does not automatically ...
rtek's user avatar
  • 53
4 votes
0 answers
141 views

Memory managment for RPC code in C

My team has been given care of an old embedded C project. Its main part is a security critical RPC API and I'm trying to create a new design of its internal interfaces to make it more robust against ...
Perseids's user avatar
  • 141
4 votes
3 answers
615 views

LRU implementation in C++ using a LinkedList

Explanation : I am adding new elements in the list until the window runs out. Head will have the earliest element and tail will have the most recent element. Once the window is over, every addition ...
piepi's user avatar
  • 823
12 votes
1 answer
3k views

My malloc() in C using mmap()

My latest school project was to implement malloc(), free(), realloc() and ...
Jon Nimrod's user avatar
2 votes
0 answers
1k views

Wrapping C++ library in C++/CLI using shared_ptr

Background: I'm writing C++ code after a fairly long time, so I may not be up to date on the best practices, so please bear with me. I'm only trying to improve and learn. Problem I need to write a ...
oczkoisse's user avatar
  • 121
3 votes
1 answer
1k views

json2CSV fails because of lack of RAM memory

I run this code on my Heroku Node.js server in order to get CSV for few hundred rows, but it fails with R14 - Memory Quota Exceeded. It worked fine when there were ...
kecman's user avatar
  • 131
3 votes
1 answer
317 views

C++ OpenGL GPU resource wrapper pattern

So with OpenGL(and I'm assuming other GPU APIs) you create different buffers/programs/etc that live on the GPU and you are given a handle to them when created. For instance, if you want a buffer to ...
Hex's user avatar
  • 425
8 votes
5 answers
5k views

Macro for allocation in C

As we all know, the syntax of allocating memory is a bit clunky in C. The recommended way is: int *p; int n=10; p = malloc(n*sizeof *p); You can use ...
klutt's user avatar
  • 903
6 votes
1 answer
193 views

Yet Another Dijkstra with real data and drawing

I've been assigned to use Dijkstra's algorithm in order to find the shortest path on real data, more specifically on Luxembourg's map. The map is an .xml file with the following structure. ...
I. S.'s user avatar
  • 347
3 votes
1 answer
918 views

Implementation of static_vector using an array of std::aligned_storage, with std::launder and forwarding

I'm trying to expand on the implementation of static_vector on the std::aligned_storage reference page, but would like to split it into two parts. First, an ...
rtek's user avatar
  • 53
1 vote
1 answer
130 views

Header-only vector implementation in C

I tried to make a generic, header-only vector thingy I can use in other projects in the future. I omitted documentation comments because it's already quite long. ...
lobstertheremin's user avatar
4 votes
0 answers
70 views

Tracker for object construction, copy, and movement

I made an object tracker for debugging and testing purposes called ccm_counter (construction, copy, move counter). It counts constructor, copy and move calls. It ...
Timo's user avatar
  • 323
2 votes
1 answer
2k views

Simple Malloc Implementation

I've written an implementation of malloc, realloc, and free. I wanted to make a ...
tay10r's user avatar
  • 250
14 votes
2 answers
3k views

malloc() and free() for Linux with system calls

I have written an implementation of malloc() and free() for Linux using the sbrk() system ...
jess's user avatar
  • 1,378
1 vote
2 answers
53 views

Lowest open space in memory

I am writing a simple compiled programming language. Everything but the bytecode interpreter can run as slow as possible, but I would like the interpreter to fun fast, because that's why I made it ...
Totillity's user avatar
  • 111
2 votes
1 answer
748 views

Reconstructing Matrix scattered over many MPI ranks

I have a program that does some matrix computations using MPI (MPICH). Each rank has a slice of the matrix and does the computations on their slice to get a new slice of the matrix. Sometimes I need ...
nick's user avatar
  • 123
7 votes
2 answers
194 views

Bash script to send notifications when low on ram

Backstory Recently, we've changed the PCs at my workplace to un Linux Mint. It works amazing, is blazing fast and the adjustment time was very short. However, I noticed my PC would freeze completely,...
Ismael Miguel's user avatar
8 votes
2 answers
4k views

Fixed-sized memory pool in C

I'm learning C and I am currently implementing a memory pool. I'm writing it in steps, first I implemented a fixed-sized memory pool then I will try to implement a memory pool with a known size of ...
Jim Morrison's user avatar
2 votes
0 answers
305 views

Yet Another Non-Intrusive Reference Counted Smart Pointer Implementation

I needed a reference counted smart pointer for my project, and for some reason early in my project, I decided that I did not like the std::shared_ptr. I can't ...
Super Cyb0rg's user avatar
5 votes
2 answers
460 views

Object pool and sorted linked list in C

Update: Have implemented some of the suggestions: See GitHub: https://github.com/BostonBrooks/MathsGame/tree/master/Object_Pools_Demo I am implementing a game engine where I have a sorted list of ...
BostonBrooks's user avatar
3 votes
0 answers
1k views

Memory release after joblib.Parallel [python]

Stuck with the issue with memory consumption - after running joblib's Parallel, deleting results and gc.collect() -ing I still have increased memory (checking by htop for process line). Found no way ...
Nikolay's user avatar
  • 31
2 votes
1 answer
1k views

C++ - Trie Implementation

I am trying to learn trie and this is my first implementation. I started off with the idea of being able to handle different data types for key and value; however, I found the data structure a bit ...
skr's user avatar
  • 539
8 votes
1 answer
2k views

Huffman Coding library implemented in C

I have written a small library for C that implements the Huffman coding algorithm as outlined in David Huffman's paper on Minimum-Redundancy Codes, and a small test program to implement it. The ...
jess's user avatar
  • 1,378
6 votes
3 answers
4k views

C# version of C++ shared_ptr

I need something akin to C++'s shared_ptr. Essentially I need an IDisposable item that I can ensure is cleaned up as soon as possible once all references have been removed, but this resource will be ...
TheBeardedQuack's user avatar
5 votes
3 answers
405 views

Python lexicon class

First time around Code Review so please be gentle (and I am happy for comments on which angles of this post are a good fit and which less so). I'm not pretty much used to software engineering in ...
matt's user avatar
  • 151
2 votes
1 answer
500 views

Deep-copyable unique_ptr wrapper with std::visit-like feature

I'm writing a simple wrapper for std::unique_ptr, which copies the pointed object when copied. Unlike this wrapper, it properly copies derived classes if ...
HolyBlackCat's user avatar
3 votes
1 answer
104 views

Pre-baked Hash table with a flat memory layout

A few notes: There is currently no non exception-based way of knowing whether a key is present in the table or not. This is intentional for my use case. Unlike the lookup process, the baking process ...
user avatar
3 votes
0 answers
506 views

Pandas data extraction task taking too much memory. How to optimize for memory usage?

I need to process some data (one of its columns contains a json/dict with params- I need to extract those params to individual columns of their own; catch- some rows have some parameters, others have ...
James Kumar's user avatar
6 votes
3 answers
552 views

Print strings in order with dynamic arrays

I accomplished the following task to practice allocating on the heap. reading words from stdin sorting them in lexicographical order printing the sorted words to stdout To accomplish this is ...
Sandro4912's user avatar
  • 3,046
4 votes
2 answers
2k views

Object pool for allocating generic objects in aligned memory

I made a single header object pool for use in personal projects. It's supposed to be easy to use, cross-platform and thread safe. It uses a free list for allocations and a hashmap for dereferencing ...
Babar Shariff's user avatar
5 votes
1 answer
191 views

Block Allocation in Fixed-Size Block Allocator

The following routine is the block-allocation procedure in a fixed-size allocator being written for library use. It is designed to be accessed from C++ (the un-mangled symbol name is ...
Lux's user avatar
  • 153
4 votes
3 answers
2k views

A Stack Template

Why you're here: Today I bring you a simple Stack Machine and a Lot of questions. I am trying to gain a little bit more understanding of pointers, memory management and templates and thought a Stack ...
Summer's user avatar
  • 2,334
9 votes
2 answers
269 views

Tail implementation using a dynamic queue library

As per K & R exercise 5-13 Write the program tail, which prints the last n lines of its input. By default, n is 10, say, but it can be changed by an optional argument, so that ...
jess's user avatar
  • 1,378
4 votes
0 answers
401 views

SoundBoard in C++ Using Qt

I've been working on a soundboard software for tabletop games audio immersion in C++ using Qt. The software consists of 2 tabs who provides to a game master a set of individual sounds or scenes to be ...
PVPJCJ's user avatar
  • 41
6 votes
3 answers
1k views

Implementation of K&R Malloc

This is a one file implementation of K&R Malloc. It's passed all test cases I've run on it, so I would like to request a code review. my_malloc.c ...
McLemore's user avatar
  • 389
1 vote
2 answers
2k views

Eight Queens Recursive

I am working on a Java textbook chapter on recursion, and I am to implement an Eight Queens solution using recursion. Though I know that I am to post working code in Code Review, I do believe this ...
Jack J's user avatar
  • 217
8 votes
2 answers
661 views

Custom fixed-space block memory allocator

This is a fixed-size memory allocator. The core memory block is an unsigned char pointer which gets allocated on initialization. Other than that, it has pretty basic allocation and block safety ...
mrsaturn110's user avatar
10 votes
2 answers
6k views

Yet another implementation of malloc() in C

I'm really curious to know someone else's opinion on this implementation. Specifically, I would be interested to know the way you would have implemented it. Here the list of issues I've found with in ...
nullbyte's user avatar
  • 415

1 2 3
4
5
13