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
866 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
59 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
38 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 (...
7
votes
1answer
865 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 ...
9
votes
2answers
187 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
1answer
968 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 ...
2
votes
1answer
41 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 ...
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
1answer
67 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 : ...
4
votes
0answers
71 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 ...
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 ...
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 ...
2
votes
0answers
354 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
2answers
67 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 ...
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 ...
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 ...
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 ...
6
votes
3answers
15k views

Replace space with %20

This is not very memory-efficient. Can you please suggest a better way or improvement? ...
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 ...
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
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
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 ...
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
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. ...
4
votes
3answers
178 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, ...
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 ...
12
votes
2answers
1k views

Using the CMA-ES algorithm to optimize the position of wind turbines

I have an implementation of an optimization algorithm called the Covariance Matrix Adaptation Evolutionary Strategy (CMA-ES). I am using this algorithm to optimize the position of wind turbines inside ...
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
246 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 ...
3
votes
2answers
1k views

Timing how long garbage collection is taking in C#

I'm concerned about how much time my application could be spending during garbage collection so I'm trying to figure out how to add some code to instrument this. Based on some examples: https://msdn....
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....
7
votes
2answers
120 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,...
19
votes
3answers
5k views
3
votes
1answer
389 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 ...
3
votes
1answer
545 views
7
votes
5answers
2k 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 ...
9
votes
1answer
247 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 ...
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
516 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 ...

1
2 3 4 5
12