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
10
votes
1answer
805 views

Customization of memory class C++

I have implemented a customized memory allocation class template for an assignment. Codes are commented; Hopefully it's clear. I would love to know if there is any way to make the code more optimized. ...
3
votes
1answer
54 views

Workbook _open copy-paste reference sheet (30k+lines) from other workbook on change only

Working on finding a way to reduce in-cell formula size and memory usage of my excel workbook, i came up with the idea to "load" (copi-paste) the reference sheet i was mentioning a lot with ...
6
votes
0answers
34 views

Subtracting elements of datasets of an HDF5 file

I am trying to solve the following problem: Input: Input is two arrays (Nx4, sorted in column-2) stored in datasets-1 and 2 in HDF5 file (input.h5). N is huge (...
2
votes
1answer
40 views

Proper way of deallocating memory in SLL?

So I'm making my own singly linked list class, with methods that you'd expect such as remove() and insert(). I don't use ...
4
votes
1answer
66 views

C++ Dynamic Array Class Testing

I'm creating a basic Dynamic Array class in C++, and I'd like to know if there are any bugs/memory leaks I haven't noticed yet. dyn_arr.h : ...
1
vote
1answer
93 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 ...
4
votes
0answers
70 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 ...
4
votes
2answers
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. ...
4
votes
1answer
69 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 ...
2
votes
1answer
53 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 ...
3
votes
2answers
66 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 ...
3
votes
0answers
33 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 ...
2
votes
0answers
55 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 ...
0
votes
1answer
66 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 ...
1
vote
0answers
22 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 ...
7
votes
1answer
144 views

Safe new/delete

A student was having problems with memory management so I put together an overload of global operator new and global ...
0
votes
1answer
38 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 ...
3
votes
1answer
83 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 ...
2
votes
4answers
109 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 ...
4
votes
3answers
116 views

Rotate square matrix clockwise by 90degrees

...
0
votes
3answers
99 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 ...
1
vote
1answer
81 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 ...
7
votes
2answers
1k 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 ...
5
votes
1answer
110 views

Linked list: removing first element

Method 1: ...
11
votes
5answers
3k 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 ...
2
votes
0answers
33 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 ...
4
votes
3answers
128 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 ...
4
votes
1answer
39 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. ...
7
votes
2answers
333 views

A lightweight version of std::shared_ptr<T>

I wrote a simple lighter version of std::shared_ptr<T> called res_ptr<T>. ...
5
votes
1answer
35 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 ...
4
votes
1answer
63 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 ...
5
votes
0answers
243 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 ...
2
votes
1answer
111 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....
3
votes
1answer
382 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 ...
1
vote
1answer
161 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 ...
5
votes
2answers
113 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. ...
10
votes
1answer
512 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 ...
-3
votes
1answer
305 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 ...
4
votes
1answer
67 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...) ...
1
vote
0answers
64 views

Managing millions of objects in a MMO game server [closed]

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
2k 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
68 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. ...
6
votes
2answers
1k 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 ...
3
votes
1answer
365 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 ...
4
votes
3answers
177 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
120 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
58 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
84 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
65 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
57 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 ...

1
2 3 4 5
12