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
1 answer
97 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. ...
user avatar
4 votes
0 answers
67 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 ...
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 ...
user avatar
  • 250
12 votes
2 answers
2k views

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

I have written an implementation of malloc() and free() for Linux using the sbrk() system ...
user avatar
  • 1,350
1 vote
2 answers
48 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 ...
user avatar
  • 111
2 votes
1 answer
568 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 ...
user avatar
  • 123
7 votes
2 answers
151 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,...
user avatar
8 votes
2 answers
3k 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 ...
user avatar
2 votes
0 answers
261 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 ...
user avatar
5 votes
2 answers
409 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 ...
user avatar
3 votes
0 answers
859 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 ...
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 ...
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 ...
user avatar
  • 1,350
6 votes
3 answers
3k 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 ...
user avatar
5 votes
3 answers
382 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 ...
user avatar
  • 161
2 votes
1 answer
415 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 ...
user avatar
3 votes
1 answer
100 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
501 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 ...
user avatar
6 votes
3 answers
465 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 ...
user avatar
  • 2,986
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 ...
user avatar
5 votes
1 answer
182 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 ...
user avatar
  • 153
4 votes
3 answers
1k 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 ...
user avatar
  • 2,324
9 votes
2 answers
235 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 ...
user avatar
  • 1,350
4 votes
0 answers
367 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 ...
user avatar
  • 41
4 votes
2 answers
978 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 ...
user avatar
  • 379
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 ...
user avatar
  • 217
8 votes
2 answers
540 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 ...
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 ...
user avatar
  • 415
4 votes
3 answers
4k 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 ...
user avatar
  • 41
1 vote
1 answer
607 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 ...
user avatar
2 votes
2 answers
170 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 ...
user avatar
28 votes
5 answers
5k 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 ...
user avatar
9 votes
2 answers
6k views

Fast pool allocator for games in C++

I have implemented the following pool allocator in C++: ...
user avatar
5 votes
2 answers
359 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 ...
user avatar
  • 151
3 votes
0 answers
307 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 ...
user avatar
9 votes
4 answers
2k 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 ...
user avatar
4 votes
1 answer
515 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 ...
user avatar
  • 283
5 votes
2 answers
448 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: ...
user avatar
3 votes
1 answer
208 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 ...
user avatar
  • 131
1 vote
0 answers
81 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 ...
user avatar
  • 131
1 vote
0 answers
28 views

ManuallyCompletableOperation for OperationQueue

Here is a very handy subclass of Operation that allows to do asynchronous tasks inside an OperationQueue: ...
user avatar
  • 153
5 votes
1 answer
1k 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 ...
user avatar
  • 1,350
-1 votes
3 answers
95 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 ...
user avatar
  • 131
12 votes
2 answers
2k 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 ...
user avatar
2 votes
1 answer
134 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 ...
user avatar
  • 2,009
0 votes
1 answer
2k 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 ...
user avatar
1 vote
1 answer
2k 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 ...
user avatar
2 votes
4 answers
4k 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 ...
user avatar
  • 247
-3 votes
1 answer
7k 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 ...
user avatar
2 votes
1 answer
92 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 ...
user avatar
  • 283

1 2 3
4
5
13