Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
0answers
60 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 ...
4
votes
2answers
86 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
43 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
74 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
128 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
1k 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
222 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
64 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
64 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
39 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 ...
5
votes
3answers
99 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 accomplish this is allocate the size ...
1
vote
0answers
27 views

Downloading, decrypting and merging of file parts

I'm trying to download multiple file parts and merge them into one file: ...
0
votes
0answers
52 views

Memory management - Large amount of data

Context I created a bundle to run asynchronous actions (using RabbitMQ) from data extracted by a service named extract_rule in the bundle context. There are some definitions from documentation : An ...
4
votes
2answers
234 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
54 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
233 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
168 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
72 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
134 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
137 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 ...
4
votes
0answers
58 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
2k 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
337 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
129 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
73 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 ...
27
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 ...
6
votes
1answer
501 views

Fast pool allocator for games in C++

I have implemented the following pool allocator in C++: ...
5
votes
2answers
103 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
210 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 ...
3
votes
1answer
127 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
103 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
81 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
65 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
19 views

ManuallyCompletableOperation for OperationQueue

Here is a very handy subclass of Operation that allows to do asynchronous tasks inside an OperationQueue: ...
2
votes
1answer
284 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
80 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
77 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
257 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
0answers
86 views

Memory leak in pixel reading class, Gdk::Pixbuf::create

I am trying to teach the Google Chrome dinosaur (the one that appears when you have no Internet connectivity) how to avoid obstacles. For this, I have written a genetic algorithm to select the fittest ...
1
vote
1answer
316 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
802 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
5k 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
62 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
241 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 ...
3
votes
3answers
392 views

Fastest FIFO with macros for use embedded devices

Objective I'm totally aware that there are dozens of FIFO implementations, but on small, low power microcontrollers every processor cycle and byte of RAM can matter significantly. Because it is used ...
-3
votes
2answers
922 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 ...
3
votes
1answer
311 views

Templated Game Resource Manager

After scanning some of the questions here about resource managers I've made some changes, and while it is much improved I still feel it's not quite up to snuff. It tried to make it work for all data ...
2
votes
1answer
374 views

Fixed-size C++ object pool, contiguous storage, O(1) random access, alloc and free. One header-only

I have implemented a rather simple object pool for the sake of entities in my game world, and it works quite well. Advantages: Elements stay in contiguous memory - can be iterated just like in an ...