Skip to main content

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
0 votes
1 answer
56 views

I have a pytorch module that takes in some parameters and predicts the difference between one of it inputs and the target

One instance of the following module uses up to almost 75% of my vram. So, I was wondering how I could improve that without slowing down runtime too much. The code is below: ...
Noah Lott's user avatar
1 vote
0 answers
101 views

Allocate managed objects in C# on the native heap

This is a pretty basic class to allocate objects from the native heap. The whole process goes as follows: allocate bytes from NativeMemory.Alloc, set the method table pointer from an existing object, ...
InfiniPLEX's user avatar
1 vote
1 answer
120 views

Javascript Signals implementation

I've created my own implementation of signals in typescript, inspired by the proposed tc39 specification (https://github.com/tc39/proposal-signals) in the BOM. I think it would be great if I could use ...
enzoaicardi's user avatar
1 vote
0 answers
61 views

Presence of UB and memory usage of a std::array initialization: version with temporary array on heap

I proposed several techniques to answer to https://stackoverflow.com/q/78672409/21691539. A classical way to answer would be to use std::index_sequence-based ...
Oersted's user avatar
  • 347
4 votes
3 answers
658 views

Error handling for singly linked list in C

I have seen many list implementations in C in this site; I know its been asked many times. I need some advice regarding: Quality of my code, especially my list library. How to handle errors in main (...
Sai_krishna's user avatar
3 votes
1 answer
229 views

Presence of UB and memory usage of a std::array initialization

I proposed several techniques to answer to https://stackoverflow.com/q/78672409/21691539. A classical way to answer would be to use std::index_sequence-based ...
Oersted's user avatar
  • 347
5 votes
1 answer
190 views

Unit Tests for an Arena Allocator

In my last post about the allocator, I received some comments about unit-tests: The code looks correct on the majority of the cases, I will suggest run valgrind or define a good set of unit tests ...
Harith's user avatar
  • 9,777
4 votes
2 answers
910 views

OpenGL: Freeing allocated memory

Here's a snippet of my code. I have a Button structure made up by 2 Figure structures, which contains vertices, colors and the relative VBOs and VAO. I have a function to allocate the memory and one ...
mikyll98's user avatar
  • 143
2 votes
1 answer
88 views

Generic container wrapper type with a default underlying buffer (2nd rev)

This is a revision of the previous question. I was told to ask an additional question with more context for the modified code to be reviewed. The changes: changed from ...
digito_evo's user avatar
5 votes
1 answer
298 views

Generic container wrapper type with a default underlying buffer

I've come up with a type that allows me to encapsulate any container class (that supports std::pmr::polymorphic_allocator<T>) with a buffer and a memory ...
digito_evo's user avatar
3 votes
1 answer
159 views

initializing a timezone database and getting all timezone names (before main())

I have written the below small program that tries to initialize a tzdb before the main() runs. So once the main function runs, it checks the two global variables (...
digito_evo's user avatar
7 votes
2 answers
270 views

An Arena/Bump Allocator in C (Follow-up)

This is a follow-up to: An Arena/Bump Allocator in C. LOC: 234. (Not including the sample tests, still quite small and manageable.) The allocator uses C99, but sample tests use C11's ...
Harith's user avatar
  • 9,777
4 votes
1 answer
315 views

Use of double pointers and memory allocation/deallocation

I've made an associative array data structure (more details in the code comments below). What I'm interested in getting a critique on is the usage of double pointers. Are they necessary here? Am I ...
denvaar's user avatar
  • 143
3 votes
1 answer
344 views

First dynamic array in C

I am new to C and have been learning it for about a month now. This is my attempt to implement a dynamic array. My code works, but i don't know whether or not it leaks memory. But my code works as I ...
Logeshwaran K's user avatar
4 votes
1 answer
173 views

Track and trace allocations

When testing or debugging allocator-aware objects, it can be useful to provide allocators that can provide insight into how they get called. The Tracing_alloc from ...
Toby Speight's user avatar
  • 81.7k
2 votes
3 answers
222 views

Prevent stack memory usage for recursive function in C

This C code does DBSCAN - Density-based spatial clustering of applications with noise. It's a cluster algorithm for turining unsupervised (no labels) data to become ...
euraad's user avatar
  • 183
2 votes
4 answers
181 views

Comparison of two excel files ignoring line order

Below is a simple method which compares contents of two excel files ignoring the line order. This method is working as expected. But, one of my peers in their code review mentioned that initializing ...
AutoTester999's user avatar
6 votes
1 answer
209 views

My attempt at GNU echo in rust

This is my first post. I'm trying to learn Rust and I recently finished reading the Rust Book. For further learning I decided to try to reimplement some GNU core utilities in Rust. This is my approach ...
roocker's user avatar
  • 61
0 votes
3 answers
78 views

another Merge Sort

I've tried to implement merge sort in c with varying degrees of success, one was correctly sorting the array but leaking memory, one was neither sorting the array and leaking memory. The following was ...
Voiceroy's user avatar
  • 103
4 votes
2 answers
257 views

C++ heap allocator using an explicit free list

Description I've written a heap allocator in C++ using an explicit free list for organization. I've also written a series of unit tests and a microbenchmark using Catch2. At time of writing I've ...
pdm's user avatar
  • 307
4 votes
1 answer
102 views

Buddy - Algorithm in Rust

I wrote my first code in Rust and decided to recall the buddy algorithm, which I suggested at work for our embedded software. I hope you can give me some advise on things like: How to make it safe (...
Niclas's user avatar
  • 151
17 votes
5 answers
5k views

malloc() and free() implementation

I'm looking for a code review of my custom memory allocation library (written for educational purposes), which includes malloc(), ...
Harith's user avatar
  • 9,777
2 votes
0 answers
49 views

Reusable storage for array of objects V4

Here is a thirdfollow up on Reusable storage for array of objects, Reusable storage for array of objects V2 and Reusable storage for array of objects V3, taking into account the provided answers. The ...
Oersted's user avatar
  • 347
1 vote
1 answer
52 views

Reusable storage for array of objects V3

Here is a second follow up on Reusable storage for array of objects and Reusable storage for array of objects V2, taking into account the provided answers. The following code should be compliant at ...
Oersted's user avatar
  • 347
3 votes
1 answer
68 views

Reusable storage for array of objects V2

Here is a follow up on Reusable storage for array of objects, taking into account the provided answers. The following code should be compliant at least with gcc, <...
Oersted's user avatar
  • 347
4 votes
2 answers
498 views

Reusable storage for array of objects

My goal is to have a memory pool non-template class that is used to store arrays of objects. The same memory pool object must be reusable for a different array (difference size, different type and/or ...
Oersted's user avatar
  • 347
2 votes
1 answer
98 views

Yet another std::unique_ptr implementation

I know I haven't implemented many methods, and haven't specialized it for T[], but I just want to see if what I coded is good or bad. ...
jamesee's user avatar
  • 21
7 votes
2 answers
208 views

shared_ptr implementation code - first cut

I've written an implementation of shared_ptr. It doesn't support weak_ptr (yet) but below is the code. I'd appreciate any feedback, comments. ...
Greg's user avatar
  • 71
6 votes
1 answer
1k views

Simple stack allocator in C

My plan is to allocate a fixed amount of static memory at initialization (a few MBs), and use a stack allocator for quick temporary buffers. The idea is to avoid calls to ...
KTSnowy's user avatar
  • 63
5 votes
2 answers
649 views

Construct mesh from a point cloud

I have been developing a program with C lately, its purpose over the top is to reconstruct meshes from point clouds which are generated by finding the intersection points of numerous rays fired at the ...
Di0n's user avatar
  • 51
-1 votes
1 answer
302 views

Copying allocated data into std::map in a smart way [closed]

I come across a problem and I solved it. The solution works but I have some feelings that there is something wrong with my solution/code. To be clear, let's assume that cars on the race track transmit ...
unique's user avatar
  • 245
3 votes
1 answer
115 views

Doubly-linked list functions

This is my first time implementing a doubly-linked list. I would like some feedback on my code. Any comment would be appreciated regarding the quality of the code, bad implementation, memory ...
Toideki's user avatar
  • 31
6 votes
3 answers
2k views

Implementation of a shared pointer constructors and destructor

I am writing my simple shared pointer. I am asking to review existing functions (understand that my implementations is not full, e.g now operator*) Review please ...
mascai's user avatar
  • 379
6 votes
1 answer
484 views

Doubly linked list first fit free list malloc/free in Python

As an exercise I've implemented malloc and free in Python as a first fit free list as described here. This tracks which blocks are free in a doubly linked list that is sorted by the address of the ...
Xander Dunn's user avatar
0 votes
1 answer
158 views

Multiple containers share a single memory resource

In my project, I'm trying to use the std::pmr allocator and monotonic_buffer_resource. I'm using vector in various classes, and ...
goodman's user avatar
  • 103
1 vote
2 answers
1k views

C Arena (pool allocator)

I wrote a pool allocator (Arena) for a compiler I'm writing. My use case for this allocator is for storing the parse tree because it allows me to free all the memory at once, so I don't need to keep a ...
Itai Nelken's user avatar
10 votes
5 answers
3k views

Implementation of a two-dimensional array in C

I implemented a two-dimensional array in C and would like to know if the implementation is sound in terms of Memory management Potential bugs and other side effects that I missed Code style (...
Gilfoyle's user avatar
  • 1,167
3 votes
2 answers
397 views

Implementation of a market that matches bids to offers

This is my task: Each line in the file can be one of the following: Updates to the limit order book in the following format: ...
Данил Денк's user avatar
5 votes
1 answer
589 views

Simple Memory Arena

A memory arena implementation targeting standard C - this is draft code for Slider 3 (https://mrsename.blogspot.com/), a new programming language implementation being developed. Other memory arena ...
Thisis Afal Sename's user avatar
5 votes
4 answers
2k views

StringPool in C++

I wrote a simple string pool for my compiler in C++ and want to hear your thoughts on its design. String pool has 2 functions: intern and ...
gavrilikhin.d's user avatar
4 votes
1 answer
493 views

Simple slab allocator in C

Here is the plan: a slab takes up 1 page and it has PGSIZE / blocksize amount of blocks the minimum blocksize is 8 bytes, otherwise the pointer to the next block ...
runningupthatroad's user avatar
3 votes
2 answers
202 views

Ray tracer in c running slowly

I was learning C the past few days and decided to make a mini project to get a better feel for it following the Ray Tracing In a Weekend Series. I got it working however I feel like it is pretty slow ...
Aayush's user avatar
  • 61
3 votes
4 answers
2k views

Read arbitrary length strings in C

This is a classic thing to want to do since it's in C that one doesn't have the std::string of C++ and input of Python. I ...
Leonardo Lovera's user avatar
1 vote
1 answer
334 views

Virtual memory manager in C

Virtual Memory manager that has functions, mappage, unmappage, remappage If the physical ...
runningupthatroad's user avatar
3 votes
1 answer
334 views

Bitmap page allocator in C

Bitmap page allocator that scans the bitmap linearly looking for size amount of pages. Everytime it founds a free page, it check if the next ...
runningupthatroad's user avatar
2 votes
1 answer
198 views

Priority Job/Task Queue for Linux (sockets and multithreading)

Preface Please review my implementation of a job queue for linux/unix systems. This is my first time coding in C, although I have quite some experience in C++. I know this is a moderate amount of loc, ...
infinitezero's user avatar
0 votes
1 answer
565 views

Count the number of objects created statically and dynamically in C++

I have written below program to count the number of static and dynamically created object of the class. ...
Naveen Gupta's user avatar
2 votes
0 answers
70 views

Virtual memory manager, physical memory manager and buddy allocator

I'm writing memory manager for my toy operating system and I would like to get some feedback. There is physical memory manager, which uses bitmap, virtual memory manager which uses buddy algorithm for ...
Mateusz's user avatar
  • 21
4 votes
1 answer
777 views

C++ disk-file memory resource

After writing a C++ simulator for malloc() and free(), (C++ imitation of glibc malloc(), free()), I thought: "My simulator ...
frozenca's user avatar
  • 1,713
10 votes
1 answer
265 views

C++ imitation of glibc malloc(), free()

I wrote a C++ simulator that performs algorithms for glibc malloc() and free(). The core logic is basically the same, with the ...
frozenca's user avatar
  • 1,713

1
2 3 4 5
13