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.

50 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
0answers
188 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 ...
5
votes
0answers
416 views

Specialty tree structure - BK Tree

I've been working on a implementation of specialty tree structure called a BK-Tree (more here and here). Basically, it's a tree that allows relatively efficient querying for items within a specific ...
4
votes
0answers
47 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 ...
4
votes
0answers
172 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 <...
4
votes
0answers
85 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
0answers
60 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 ...
4
votes
0answers
122 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
0answers
201 views

Cleaning up memory after loading Access DB into a datagrid

I wrote an app that pulls a MS Access DB into a DataTable and then displays it into a WPF datagrid. The dialog window has a search button which calls on a class ...
4
votes
0answers
276 views

cross-platform stdlib-only aligned allocator in C++14

I'm writing a program which uses OpenCL, and the OpenCL types are mostly over-aligned. Sometimes when using stl containers with these types, I'd get segfaults, so I tried to write my own aligned ...
3
votes
0answers
44 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. <...
3
votes
0answers
94 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. ...
3
votes
0answers
178 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 ...
3
votes
0answers
282 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 ...
3
votes
0answers
255 views

Applying Scikit-Learn Linear Kernel with a generator for low memory pressure

matrix = # a sparse matrix of TFIDF vectors - 28458x3218988 My aim was to create a similarity matrix comparing all documents to all documents using ...
3
votes
0answers
393 views

Attempt at multithreaded memory allocator

I'm trying to learn C and memory management, therefore as an exercise I've written a memory allocator. I've taken the best fit algorithm and added multithreading with locks. I'm a beginner with ...
3
votes
0answers
404 views

Populate MongoDB with random documents using a Go channel

I recently created a small app in Go that generates random bson documents and insert them in a database (MongoDB). See this question for details. After doing some profiling, I realised that garbage ...
3
votes
0answers
146 views

A way to automatically reorder struct fields by their sizes in descending order

Using constexpr and preprocessor magic it is possible to cook a struct which have a minimal size between all possible sizes, keeping all the data members properly ...
3
votes
0answers
33 views

Using STORAGE macro using QSAM for input/output

I was wondering if you can help me out. I wanted to know if there is an easier way to do the following. My code works but I feel like there is a lot things going out with multiple loops and wanted to ...
3
votes
0answers
273 views

Cache with timeout per key

I wrote a general purpose library for in-memory cache with custom timeout for each key. ...
3
votes
0answers
519 views

Parsing and producing sets of financial CSV files

I have this small Haskell script that I wrote some time ago to parse a set of financial CSV files to produce other CSV files. I've recently had a problem with large input files (around 300Mb) that I ...
3
votes
0answers
1k views

Integrating SFML and Box2D lib, and a Mass Production Shape Factory

I've just written two new headers: one that integrates Box2D and SFML by a class called BodyRep which creates/ is a graphic representation of any body, and one that ...
2
votes
0answers
15 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 ...
2
votes
0answers
35 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 ...
2
votes
0answers
133 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 ...
2
votes
0answers
151 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 ...
2
votes
0answers
317 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
0answers
379 views

Partial file encryption with AES

Task is to encrypt part of the file using aes encryption algorithm. I did ...
2
votes
0answers
460 views

Get process max memory usage while copying large data

I want to check the memory usage of a process before and after I copy a large file or folder, and also, I want to get the maximum memory usage during file operation. Is this a good method? ...
2
votes
0answers
268 views

Low performance of HTTP request using Haskell wreq

The program makes HTTP requests (checks video stream status) and calls an external program. ...
2
votes
0answers
252 views

Fetching a weather report on an Arduino from a web service

I'm writing some code which is basically supposed to http get some information from my own website and parse it, which (finally) works. However, when I compile the code, it shows this: Sketch uses ...
2
votes
0answers
269 views

Implementation of a lock-free fixed-sized allocator - follow-up - with commented code

The following implementation of a lock-free fixed-size allocator is a follow-up of: Implementation of a lock-free fixed-sized allocator §1 - Introduction The purpose is self-learning of atomic ...
2
votes
0answers
81 views

Platform independent leak/cyclic dependency detection of objects

Sometime back I came across a bug where a particular object was leaking but it was very hard to identify the root cause. I knew that it was due to a cyclic dependency (which usually indicates a bug in ...
2
votes
0answers
96 views

D3D COM Object Pooling

I'm using the following pattern to pool D3D objects globally in my application. Is it a good idea (alternatives)? Is it thread-safe? ...
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 ...
1
vote
0answers
74 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
20 views

ManuallyCompletableOperation for OperationQueue

Here is a very handy subclass of Operation that allows to do asynchronous tasks inside an OperationQueue: ...
1
vote
0answers
59 views

RFID card reader validation routine in 8051 assembly

I came up with the following code to check to see if the last 2 bytes of a 12-byte value read in from a RDM6300 card reader is actually the checksum of the first 10 bytes. ...
1
vote
0answers
49 views

Two priests talking to one another

It's a part of code where two Threads ("priests") talk to each other. One asks and waits for the second to answer - then something happens depending on what has been answered by second thread. I ...
1
vote
0answers
160 views

Custom checked_ptr (like std::shared_ptr) for projects without STL

I have written a class to encapsulate pointers for a platform, where the STL is not available. The idea is to have something similar to std::shared_ptr. However, I ...
1
vote
0answers
93 views

Memory access pattern

Here is the chunk of the code that hogs the maximum time: ...
1
vote
0answers
104 views

Helper class for accessing blobs and mmap memory - follow up

This class was inspired from Microsoft's array_view. It intended to use with mmap-ed memory for easily check bounds and so on. I probably will need to throw exceptions, but this is not my usual way ...
1
vote
0answers
190 views

Producer/Consumer write to file

I'm concerned with the memory usage of this application. When I start it and look at it's memory usage while it's waiting for input, it's memory usage is around 13,212 K. When the application runs ...
1
vote
0answers
676 views

Purging elements from the map if it reaches a memory size limit

I have implemented a LRU cache using ConcurrentLinkedHashMap. In the same map, I am purging events if my map reaches a particular limit as shown below. I have a ...
1
vote
0answers
113 views

C++ base class for heap awareness

I have a few classes that form a class hierarchy where some objects point to others. In the usual case, I create these object on the stack. In other cases, I need to clone these object to do some ...
1
vote
0answers
631 views

C++ and OpenCV memory management

I'm including all of my code, however, my major issue here is about returning the vector/array/pointer (I don't really know what to choose) in this function: ...
1
vote
0answers
49 views

Container with allocator copy assignment

I am trying to write a simple Buffer container class that will behave like std::vector. It should construct only elements that ...
1
vote
0answers
2k views

Android app with an ActionBar, a ViewPager and an AsyncTask

I'm new at Android and Java development and I've put together a demo app to start learning, which is made of: a main activity extending ActionBarActivity, in which ...
1
vote
0answers
644 views

Optimize Python script for memory which opens and reads multiple times the same files

I have code that works perfectly, but it uses too much memory. Essentially this code takes an input file (lets call it an index, that is 2 column tab-separated) that searches in a second input file (...
0
votes
0answers
52 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 ...
-3
votes
1answer
110 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 ...