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
143 views

A Pool-based Memory Management

I wrote a memory management class that is supposed to be used in a game. I decided to use "Blocks" as an in-code representation. It is written in MSVC++ and is currently not meant for ...
Raildex's user avatar
  • 133
5 votes
1 answer
735 views

3D Direct Convolution Implementation in C

For my project, I've written a naive C implementation of Direct3D convolution with periodic padding on the input. Unfortunately, since I'm new to C, the performance isn't so good. By convention, all ...
lxiangyun93's user avatar
4 votes
2 answers
1k views

Malloc and free

I'm looking for help speeding up some code I'm tinkering with. The rest of the code, as well as my 'benchmark', can be found here. ...
Lev Knoblock's user avatar
4 votes
1 answer
84 views

protein sequence translator using basic text manipulation

As an old COBOL coder, all this OOP stuff is foriegn. Would someone please take a look at this program? I'm looking for suggestions for ways to improve this program. While it works, I'm sure there's ...
Phil Huffman's user avatar
2 votes
1 answer
88 views

c++ new-handler

I had just put together my first public project: simple(sane) new-handler for c++. It allocates some reserved memory on start up, then releases it piece by piece. It may also raise a signal when each ...
zzz777's user avatar
  • 168
3 votes
2 answers
228 views

String input and split functions in C

I've some functions targeted to simplify working with strings in some of my other projects. I'd like feedback on this code and whether or not the implementation is efficient and memory safe. I work ...
Chase's user avatar
  • 197
3 votes
0 answers
138 views

Custom allocator for improved cache locality and fast iteration in C++

I am writing a custom allocator for my educational game engine project where I need to iterate through a collection of components(similar to Unity3D) every frame. There are game objects and every game ...
Vignesh Gunasekaran's user avatar
2 votes
1 answer
187 views

dumb::vector - a class for students to use when they are expressly forbidden from using std::vector

I have created a small library for use by beginner C++ students who are forbidden from using std::vector in their projects. Because of this, I would like you to ...
JohnFilleau's user avatar
0 votes
1 answer
91 views

Inheritance with Singletons [closed]

The problem / background I have a project, BusinessProject, that currently stores some static data in memory using the Singleton pattern - we'll call this class ...
laventnc's user avatar
1 vote
0 answers
174 views

Reduce memory usage/lag with multiple large JSON files coming in through XHR

I need to show a map of the United States using Leaflet, where if the user clicks on a state, the map zooms in to view all of the state's census tracts. I need to do this without a significant delay ...
brienna's user avatar
  • 243
6 votes
1 answer
284 views

Safe new/delete

A student was having problems with memory management so I put together an overload of global operator new and global ...
Aykhan Hagverdili's user avatar
0 votes
1 answer
50 views

Code to write a C template file [closed]

I am writing code to write a C template file; the executable takes two arguments (main) <file name> and ...
Shashwat D's user avatar
4 votes
1 answer
122 views

Unique and shared resource owner

I need a unique_ptr and shared_ptr like structure, but instead of pointers, I would like to store some kind of reference to a ...
Adam's user avatar
  • 63
2 votes
4 answers
131 views

I'm deallocating objects created but I'm unsure whether my code is leaking memory or not

I have a simple application which requires the user to input details about students and their grades. I have two different classes Student and ...
mhmrhiman's user avatar
3 votes
3 answers
285 views

Rotate square matrix clockwise by 90degrees

...
kesarling He-Him's user avatar
0 votes
3 answers
118 views

Safer & simpler allocation functions and macros

I wrote a bunch of functions and macros for safer and simpler allocation. They are documented in their files. Disclaimer: The library requires POSIX extensions, GCC extensions, and LIBBSD ...
alx - recommends codidact's user avatar
1 vote
1 answer
308 views

Custom bounded memory pool allocator

Recently I put together a custom fixed size (bounded) memory pool for my job system implementation to support its internal memory management. Since it will be accessed by different threads I want to ...
Caiwan's user avatar
  • 155
8 votes
2 answers
2k views

Leak detection simple class

Basic idea is to use a Class, with static methods to add and remove references in a static vector, that keeps track of these references, and check that vector upon exit. The class is detecting ...
User's user avatar
  • 93
5 votes
1 answer
784 views

Linked list: removing first element

Method 1: ...
OverLordGoldDragon's user avatar
11 votes
5 answers
4k views

Python's .split() implemented in C

I'm new to the C programming language and I just made a basic version of Python's split() function using C. Note: A major functionality I chose not to implement is ...
Dewamuval's user avatar
  • 223
2 votes
0 answers
100 views

A lightweight version of std::shared_ptr<T> V2

This is a lightweight version of std::shared_ptr<T> called res_ptr<T> This post is a continuation of: A lightweight ...
ALX23z's user avatar
  • 2,253
4 votes
3 answers
414 views

Simple shared pointer implementation in a single threaded environment (revised)

std::shared_ptr does not stop you from having the same resource managed by multiple control-blocks (and thus independent sets of shared-pointers), even though it is ...
frank's user avatar
  • 85
4 votes
1 answer
71 views

simple shared pointer implementation in single threaded environment

Update: The code below has some obvious problems, and it is not allowed to revise code in the original question, so I have to post a new question, the revised code is here. ...
frank's user avatar
  • 85
7 votes
2 answers
545 views

A lightweight version of std::shared_ptr<T>

I wrote a simple lighter version of std::shared_ptr<T> called res_ptr<T>. ...
ALX23z's user avatar
  • 2,253
5 votes
1 answer
50 views

Finding the largest jacobian in a finite element mesh

So I'm trying to implement the following problem in a couple of different languages to get a rough idea of how different languages work & feel. I'm completely new to C, and this is the first code ...
Psirus's user avatar
  • 203
4 votes
1 answer
85 views

C Garbage Heap aka simplest memory management tool

The idea is to init garbage heap in the beginning of main, use gmalloc, gcalloc and ...
sanyassh's user avatar
  • 315
5 votes
0 answers
996 views

Polymorphic deleter for unique_ptr

There is a basic difference in the way C++ manages the deleter for std::unique_ptr and std::shared_ptr, mainly for allowing ...
Amir Kirsh's user avatar
2 votes
1 answer
213 views

Remove duplicates from an unsorted Linked List in Ruby

Currently I'm going over the cracking the coding interview. I'm in the Linked List 2.1 question which is as follow: Remove Duplicates, write code to remove duplicates from an unsorted Linked List....
Steven Aguilar's user avatar
4 votes
1 answer
3k views

Implementing sbrk for a custom allocator in C

I took on a for-fun task of creating a memory allocator which uses process memory rather than making a bunch of system calls to the operating system. The task was: implement my own ...
the_endian's user avatar
  • 1,343
1 vote
1 answer
592 views

Fast insert, fast removal and fast access object pool C++ container

I just want to gather some feedback about this container, in my view it solves the problem of common data containers which don't have fast access and fast deletion. I want to admit that I have not ...
jokoon's user avatar
  • 293
5 votes
2 answers
215 views

MVVM model letting the user select a directory in a testable manner

My application needs to let the user select a folder from somewhere on their local machine. Below are the interface and model pair that I have written to let the user do so. ...
Toby Smith's user avatar
10 votes
1 answer
2k views

Static block memory allocator

I've found a little task to create a block memory pool allocator. This allocator is required to allocate memory in single fixed-sized blocks from the pool in static memory. Sizes of block and pool are ...
Michael K's user avatar
  • 103
-3 votes
1 answer
708 views

Binary tree algorithm for 2D bin packing

I have re-implemented in C++ an algorithm already in JavaScript available here and there. C++ code works fine, but I have memory management concerns: I allocate memory with such statement as ...
Megidd's user avatar
  • 145
4 votes
1 answer
413 views

Single-thread Task Scheduler with type erasure and allocator-aware

I made a task scheduler to practice allocators and type erasure. With my project, you can delay execution of any callable (functions (using std::ref), lambdas...) ...
Julien Vernay's user avatar
14 votes
2 answers
5k 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....
VisualMelon's user avatar
  • 7,421
1 vote
1 answer
105 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. ...
Danilo's user avatar
  • 195
7 votes
2 answers
6k 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 ...
AFrueh's user avatar
  • 73
3 votes
1 answer
2k 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 ...
Mongus Pong's user avatar
4 votes
3 answers
899 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, ...
hanshenrik's user avatar
2 votes
1 answer
133 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. ...
Jacob's user avatar
  • 43
4 votes
1 answer
472 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 '...
rhughes's user avatar
  • 270
2 votes
1 answer
493 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 ...
MoonKnight's user avatar
4 votes
2 answers
79 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 ...
Remi.b's user avatar
  • 617
2 votes
0 answers
27 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 ...
LambdaBeta's user avatar
3 votes
0 answers
273 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. <...
A Blender's user avatar
9 votes
1 answer
734 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 ...
S.S. Anne's user avatar
  • 1,716
4 votes
0 answers
688 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. ...
L. F.'s user avatar
  • 9,456
2 votes
1 answer
642 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 ...
Nameless's user avatar
  • 153
5 votes
2 answers
1k views

A static array implementation in C++

I'm implementing a basic array data structure with basic functionalities. ...
Bilal Ahmed's user avatar
4 votes
1 answer
1k views

Implicit Async and none async event handlers

I have implemented a event aggregator for our backend. ...
Anders's user avatar
  • 670

1 2
3
4 5
13