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
11
votes
2answers
1k views

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

I have written an implementation of malloc() and free() for Linux using the sbrk() system ...
1
vote
2answers
38 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 ...
2
votes
1answer
136 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 ...
6
votes
1answer
79 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,...
7
votes
2answers
686 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 ...
2
votes
0answers
137 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 ...
5
votes
2answers
145 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 ...
2
votes
0answers
289 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 ...
2
votes
1answer
274 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 ...
4
votes
1answer
350 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 ...
6
votes
3answers
2k 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 ...
5
votes
3answers
258 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 ...
3
votes
1answer
142 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 ...
3
votes
1answer
84 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 ...
3
votes
0answers
165 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 ...
6
votes
3answers
192 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 ...
4
votes
2answers
800 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 ...
5
votes
1answer
77 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 ...
2
votes
3answers
523 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 ...
7
votes
2answers
172 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 ...
4
votes
0answers
115 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 ...
4
votes
2answers
436 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 ...
1
vote
2answers
743 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 ...
6
votes
0answers
173 views

Custom fixed-space block memory allocator

This is a fixed-size memory allocator. The core memory block is just a unsigned char pointer which gets allocated on initialization. Other than that has pretty basic allocation and block safety ...
10
votes
2answers
4k 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 ...
4
votes
3answers
884 views

Doubly Linked List Implementation [C++]

C++ noob reporting. I'm working on implementing a doubly linked list using two separate classes: one class, called node, containing your standard doubly linked list ...
1
vote
1answer
270 views

HTTP download with dynamic reallocation and retries

This code is for downloading a file via winhttp lib, It's invoked by StartDownload function which tries to download n times before returning false if maximum tries ...
2
votes
2answers
114 views

Quick general purpose linked list in C

I want to use it when some function needs to return a list of something. Is it working as I think it should or is there undefined behavior somewhere? What I really tried to achieve is something like a ...
28
votes
5answers
4k views

C++ Vector Clone

I'm learning C++, so I decided to make a simpler clone of std::vector. Concerns: I have seen people defining methods outside of the class, and only prototyping ...
7
votes
1answer
2k views

Fast pool allocator for games in C++

I have implemented the following pool allocator in C++: ...
5
votes
2answers
216 views

Overriding operator delete/new to check correct pairs of (non-)array variants

A legacy project I am maintaining in my freetime uses overrides of operator delete / operator new. These overrides over-allocate ...
3
votes
0answers
278 views

C++ object pool using C memory pool as base

I started out with this question on Stack Overflow. I have since then gotten an official answer from the mbed developers that the MemoryPool that I was asking about only issued raw C malloc/free type ...
9
votes
4answers
1k views

Populating a structure

I'm solving K&R exercise 1-13: Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation ...
4
votes
1answer
309 views

Fixed-Size Memory Pool with alignment

After taking a break and reviewing the comments on my first attempt at creating a fixed-size memory pool, this is my second attempt. The memory pool should allocate each block correctly aligned in ...
3
votes
1answer
186 views

A free-standing weak_ptr equivalent to handle lifetime of non-shared callback objects

I've been finding myself wanting the following pattern recently: ...
3
votes
1answer
116 views

Stack allocator and C11's alignment features

I am trying to write a custom stack allocator for a game I am working on. To deal with memory alignment, I am using C11's stdalign.h header; however, since I do not ...
1
vote
0answers
74 views

Excel vba: setting a long variable for each object class dramatically increases execution time

I have a main sub that makes use of a Client class: creates an array with 100 000 Clients ...
1
vote
0answers
20 views

ManuallyCompletableOperation for OperationQueue

Here is a very handy subclass of Operation that allows to do asynchronous tasks inside an OperationQueue: ...
2
votes
1answer
653 views

dqueue - A dynamic FIFO queue library for C

This is the first draft of dqueue, a dynamic queue library written in C, with a sample program to demonstrate it. This is my first time writing any sort of library to be used as a generic subsection ...
-1
votes
3answers
85 views

Populate array with random numbers efficiently

I have an initial Excel workbook with about 100 000 rows. I put those rows into array and then use that array to create Client ...
12
votes
2answers
1k views

Weapon and Hero classes

For me as a complete newbie to the world of C++, getters and setters are a rather confusing topic. There seems to be a wide range of opinions on what constitutes a sound use of getters and setters. In ...
2
votes
1answer
105 views

Private storage for at-rest data in VBA

One major annoyance in VBA programming is that it's hard to keep a secret secret. In this particular case, it's the ADODB.Connection. For reasons not germane to the ...
0
votes
1answer
840 views

Implement a working Vending machine [closed]

Task: Design a vending machine which does the following: Accepts coins of 1, 5, 10, 25, 50 cents or notes of 1 and 2 User selections: Candy, snacks, nuts, Coke, Pepsi and soda ...
1
vote
1answer
1k views

C Implementation of dynamic mem allocation using first-fit algo

I have implemented malloc and free in C based on first-fit algo and using a circular linked list for free blocks of memory. It seems to be working based on the basic test in the main function. I would ...
2
votes
3answers
3k views

Memory allocation for linked list in C

I am new to C and am writing a basic program to calculate the arithmetic sum of two numbers stored in a linked list. My main question is idiomatic memory management in C. The program below allocates ...
-3
votes
1answer
6k views

Memory error in python [closed]

I am writing a code which returns something like 1^k + 2^k + 3^k......n-1 where k be any number.Below is my code.I am getting a memory error.How do I optimise it. Sample test case for wrong error: 1 ...
2
votes
1answer
67 views

Recursion function subtracting accumulated percentage with <<-

I have a file with percentage of presence of micro-organisms but each category has the accumulation of percentages of the child categories. I designed a recursive function to subtract the proportion ...
5
votes
2answers
914 views

Container for fast deletion and addition of elements

I need a container that is able to delete and add elements as fast as possible, without the need of reallocation that usually takes place when we push_back elements in an ...
5
votes
3answers
1k views

Fastest FIFO with macros for use embedded devices

UPDATE (a year later) Since this post the code has turned into a small library called fifofast and is hosted on github under the MIT License. This note is meant for anyone who stumbled across this ...
-3
votes
2answers
3k views

Working around a Segmentation Fault for reading Files in C [closed]

I am getting a segmentation fault on the below snippet, only when I go above a text file in the range of 80-100kb. It will read smaller files of text but otherwise ...