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
0answers
50 views

Managing millions of objects in a MMO game server [on hold]

A litle context: This game server is coded entirely on C-with-classes (plain C code using basic C++ features like classes, templates and such, to avoid any possible overhead). At startup the server ...
13
votes
2answers
1k views

Asynchronous Circular Buffer in C#

Preamble I want to be able to test methods which communicate over a simple exclusively asynchronous two-way stream-like interface which may underneath use any of a number of communication methods (e....
1
vote
1answer
58 views

Boolean class using shared referenced memory

To improve my knowledge I am trying to make a bool class from scratch, or derivative of. I am using MinGW g++11 compiler on a Windows 7 laptop. ...
5
votes
2answers
99 views

Safe Dispose of Timer

I am currently refactoring a larger solution where the compiler gave multiple warnings about disposing the used System.Timers.Timer instances. The timers are ...
1
vote
1answer
71 views

Exposing a simple struct using Rust FFI

I am trying to expose a simple struct via FFI. Is this the best way to do it? I am not 100% sure about the get_text function. This is taking the string out of the struct and cloning it before ...
3
votes
3answers
92 views

Fast-resizing uint8 buffer

I wanted a buffer like std::vector<uint8_t> which is very fast at resizing, and it does not require byte initialization (it resizes to 16K, then to 2-4 bytes, ...
2
votes
1answer
67 views

A heap-allocated texture class for a console renderer

I am working on a console renderer and I want a heap-allocated dynamic texture class. Since I am quite new to C++, I just want to check the memory management, if I destroy all pointers correctly etc. ...
0
votes
0answers
47 views

Helper to convert arbitrary function into a custom deleter

If you want to use a custom deleter in unique_ptr you either have to pass a functor or the signature of a delete function as template argument. If you have a ...
4
votes
1answer
61 views

Passing Array into Unmanaged Code for Modification

I have an array allocated in C# which I am passing into unmanaged code to be modified. The following code works, but I am not sure if there are any other more '...
2
votes
1answer
32 views

Force ConcurrentDictionary in a Singleton Registry to Collect Removed Items/Space

I have the following class which is used in a WebApi AspNetCore application as a singleton instance to store Strategy objects (reference type). The class is ...
4
votes
2answers
43 views

Command to measure CPU time and RAM usage of process while making sure it does not go over certain ressource limitation

I found some old code of mine and am trying to see if it can be improved. The goal is to write a command that measures a process's CPU time and RAM peak usage and kills the process if it exceeds a ...
2
votes
0answers
11 views

Thread safe Shareable and Splittable Buffer with Safe Memory (Project)

Backstory This is a buffer I wrote for use in multiple personal projects. It is designed to handle pretty much any data in pretty much any way. In particular I intend to use it in such instances as ...
3
votes
0answers
40 views

Simple and safe C++ pool allocator

I have written a simple pool allocator for C++ and I'm looking for ways to improve it, in speed, usability or safety. For example, I don't know how to allocate a buffer larger than the pool size. <...
7
votes
1answer
40 views

Custom malloc implementation

I have a malloc() implementation that relies purely on mmap. I'm fairly sure that it doesn't overwrite any of the internal ...
3
votes
0answers
82 views

A fixed-size dynamic array

Background I implemented the historic std::dynarray according to the specification under the name dynamic_array in C++17. ...
1
vote
1answer
54 views

Memory policy with ArrayPool<T>.Shared

i've recently released a from scratch set of library Astron, and I wanted to get my memory policy logic reviewed.(you can find a little doc about it here). My first goal was to provide an extandable ...
5
votes
2answers
104 views

A static array implementation in C++

I'm implementing a basic array data structure with basic functionalities. ...
6
votes
2answers
94 views

Unmanaged byte array to managed structure

I have a need to turn byte arrays into various structures. First version: ...
7
votes
3answers
1k 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 ...
5
votes
1answer
94 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....
4
votes
0answers
112 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 <...
5
votes
1answer
66 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....
2
votes
1answer
41 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: ...
1
vote
0answers
21 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 ...
2
votes
1answer
44 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 ...
2
votes
1answer
45 views
1
vote
1answer
25 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 ...
5
votes
2answers
123 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: ...
-1
votes
1answer
43 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 ...
2
votes
0answers
34 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 ...
4
votes
0answers
80 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 ...
4
votes
3answers
354 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 ...
9
votes
1answer
218 views

My malloc() in C using mmap()

My latest school project was to implement malloc(), free(), realloc() and ...
2
votes
0answers
82 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 ...
3
votes
1answer
122 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 ...
3
votes
1answer
102 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 ...
6
votes
5answers
1k 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 ...
6
votes
1answer
77 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. ...
3
votes
1answer
145 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 ...
1
vote
1answer
60 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. ...
4
votes
0answers
59 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 ...
2
votes
1answer
420 views

Simple Malloc Implementation

I've written an implementation of malloc, realloc, and free. I wanted to make a ...
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
131 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
75 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
601 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
133 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
138 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
275 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 ...