Questions tagged [memory-optimization]

Memory Optimization is a subset of Optimization: it is the goal of reducing the memory consumption (the amount of memory used during compile or run time) of your program or of a specific algorithm

Filter by
Sorted by
Tagged with
5 votes
4 answers
184 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 ...
3 votes
1 answer
46 views

Create a forecast matrix from time series samples

I would like to create a matrix of delay from a time series. For example, given y = [y_0, y_1, y_2, ..., y_N] and W = 5 I need to create this matrix: ...
  • 133
3 votes
1 answer
65 views

Python classes which can be used as arrays with any number of bits per index

https://github.com/speedrun-program/small_array/blob/main/small_array.py As a personal project, I wanted to try to make Snake Game in pygame where the grid can be arbitrarily large. I made these ...
4 votes
3 answers
250 views

Optimize memory and disk usage for sequences of n-bit values

Motivation: I am working with sequences of n-bit values coming from an ADC. I was initially using a std::vector<unsigned short> to store these values (12 bit ...
  • 61
6 votes
2 answers
69 views

LeetCode 126: Word Ladder II -- Memory limit exceeded

I am trying to solve LC126, and got a memory limit exceeded for the following solution. I've seen the answer here -- so I'll try to use Dijkstra as well, but I would like to understand why I get the ...
  • 266
1 vote
1 answer
165 views

Virtual memory manager in C

Virtual Memory manager that has functions, mappage, unmappage, remappage If the physical ...
2 votes
1 answer
72 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 ...
3 votes
3 answers
169 views

Discussing approaches for converting Enum to String

I need to convert the ENUM to a respective string value for which I came up with two approaches and I'm trying to see why would a second approach be better than the first one if even in terms of ...
  • 362
1 vote
2 answers
88 views

"Frequency Counter Pattern", Can we get other better algorithm having like, O(n) or O(n log n)

Problem Statement : Write a function called matchSquare, which accept two arrays (arr1, arr2) Criteria: The function should return true, if every value in the arr1, has its corresponding values ...
  • 131
0 votes
1 answer
74 views

Improving multiple FirstOrDefault statements on same collection

I'm having multiple FirstOrDefault() statements, in this case 2, on a collection. ...
  • 103
0 votes
1 answer
47 views

An algorithm that minimizes the number of ingredients necessary

I am working on a code that will minimize the number of ingredients necessary to make some dishes. Each dish can be prepared in an arbitrary large number of ways, with combinations of two ingredients. ...
0 votes
0 answers
26 views

UPDATE #2: Lengthening the time it takes to access files using function hooking

https://github.com/speedrun-program/load_extender This is the previous post: UPDATE #1: Lengthening the time it takes to access files using function hooking I came back to this to try to improve it. I'...
0 votes
1 answer
45 views

How do I increase the memory efficiency of this longest substring implementation? (C++)

I'm practicing my coding on leetcode. I implemented the following algorithm to solve the longest substring problem: ...
3 votes
1 answer
185 views

Golang function that reads S3 files and populates maps with strings as keys

I have a below read function which is called by multiple go routines to read s3 files and it populates two concurrent map as ...
  • 199
0 votes
0 answers
33 views

function for adding two 2D matrices of large size obtained by several iterations

I have defined the following function. ...
  • 101
4 votes
1 answer
178 views

Minimize memory allocations while calculating the matrix representation of a Hamiltonian

I am writing a script using Julia (calling my functions from the REPL) to compute the matrix representation of certain Hamiltonian. After I run my script I see that the memory allocations count is ...
2 votes
3 answers
72 views

Discount calculations on customer purchases

...
  • 21
4 votes
1 answer
258 views

Memory leak I can't identify using Bitmap and Graphics classes

I have some parallel.for one inside another. the last parallel.for have a normal for that ...
2 votes
3 answers
175 views

Fixed-size memory allocator

I've been trying to implement a simple Boost PMR allocator that has a fixed amount of memory. My first implementation (which can be found here) had undefined behavior and did not handle memory ...
  • 31
7 votes
1 answer
356 views

Find all possible ways a rook can move to a diagonally opposite corner without going back to an already visited square

This question seems similar to this one: Find number of unique paths to reach opposite grid corner but is entirely not. For moving from upper-left corner to lower-right corner we are not restricted to ...
2 votes
1 answer
59 views

iterating a big list of objects throws a memory issue

I'm writing a function which iterate through a list of objects and should return: true if all the items have the attributes (cp and type). false if all the items haven't the attributes (cp and type). ...
  • 123
4 votes
1 answer
135 views

Segmented Sieve of Eratosthenes with wheel factorisation

Problem I have a project in which I implemented variants of the Sieve of Eratosthenes as well as benchmarking and profiling harnesses for these (which can be ran with ...
  • 259
0 votes
0 answers
39 views

Memory Allocation problem in codewars: Improvements to use less memory : Tribonacci sequence

Consider my following code from the Tribonacci sequence kata. ...
  • 113
3 votes
1 answer
150 views

C# screen recording

I'm developing a screen recording as an application log. The recording should capture a full HD screen at 25fps and on request it should save last 60 seconds of record. It is for embedded app, but the ...
3 votes
0 answers
85 views

screen recording application

I'm developing a screen recording application using java. I've modified code from https://dzone.com/articles/screen-record-play-using-java where all the external jars required for this application are ...
  • 279
1 vote
0 answers
68 views

PHP SCRIPT OPTIMIZATION OF METHODS

Here is some php code which i think is optimized but still want to optimize it more but not sure how to do it. ...
  • 119
5 votes
6 answers
2k views

Implementation of itoa which allocates the string

This is my implementation of itoa() (Integer to Alpha), which converts an integer to a string. Memory management and optimization is important. The caller is not ...
  • 61
6 votes
1 answer
181 views

Python script which sends telegram message if Raspberry Pi's temperature crosses 60 °C

I need to know if there is any way I can optimize my code so that it does not use 0.6% of my total memory - which is approx. 22.4MB. This is a really small script that runs for as long as the ...
0 votes
1 answer
58 views

Enter the randomly displayed letter console game

The below code segments compose a simple console game where the user is prompted to enter a randomly generated letter displayed in the console. It also saves and loads user data through a .txt file. ...
0 votes
1 answer
59 views

R code optimization

I have about 977 obs in top500Stocks which contains name of 977 stocks. ...
2 votes
1 answer
344 views

Alpha beta pruning with memorization (transposition tables) and bitboards (5x5 cumulative tic-tac-toe)

This is my first time trying solve a game using these techniques. I've looked at pseudocode of alpha-beta pruning with transposition tables and rewritten it in c++. ...
  • 258
2 votes
0 answers
58 views

Dynamic heterogeneous container

I want to have dynamic continuous block of memory for different types, that inherit from single base class. I've written structure for that purpose. I know I play with a fire here, but I would like to ...
0 votes
2 answers
111 views

Fixed memory manager in C

I decided to not use heap in my program and create a custom memory manager to retrieve memory chunks from a big global array of uint8_t(u8). I chose u8 since 8 bits is a byte. The very big ...
  • 79
5 votes
1 answer
142 views

How to speed up scraping large amounts of data with Python

I have the following code: ...
3 votes
0 answers
105 views

Memcpy function optimzation

Here is my memcpy algorithm I've been working on: ...
0 votes
1 answer
70 views

Find a sum using just two different digits

The problem statement was pretty easy and I was able to run half of the test cases, but some of the test cases in the end gave me the error of memory limit reached. What can I do here to improve the ...
  • 13
2 votes
3 answers
151 views

DFS-based exhaustive word grid search

I have implemented an exhaustive depth-first grid search that searches for all possible words in the 8 connected regions. Is there any way I can make this faster or memory efficient than it is now? I ...
1 vote
1 answer
475 views

Follow-up: How can we optimizing Java BigInteger operations?

This is the follow up question of How can we optimizing Java BigInteger operations? Problem Reduce the number to 1 in a minimal number of steps, following the rules: ...
4 votes
2 answers
134 views

Minimum number of copies of an application a company needs to purchase

Some applications from vendors are allowed to be installed on multiple computers per user with specific restrictions. In our scenario, each copy of the application (ID 374) allows the user to install ...
  • 141
1 vote
0 answers
30 views

Improving interactive component performance with constant image translation

I am making this React Component for an interactive eye that moves and tracks the user's mouse cursor wherever it goes to in the webpage. However, I faced 3 problems while doing so. The eye moves as ...
  • 163
2 votes
0 answers
149 views

this VHDL code for a 64-bit timer?

I have code for a 64-bit timer register which can take in a 32-bit slice and depending on the inputs, place the slice in the high side or the low side, or increment the counter. ...
  • 187
3 votes
1 answer
112 views

Python : adding a columns with count of missing values by row

I have a big python data-frame and I am trying to add a column to it with average number of missing values by row. I have inherited some code that is working but I'd like to reduce memory usage by ...
  • 139
0 votes
1 answer
87 views

Simple C++ Dynamicly allocated Matrix with only one memory allocation [closed]

I was bothered with existing matrix allocation methods that take variable rows and columns, so I made a small class that only needs one memory allocation. ...
3 votes
2 answers
190 views

Java 8: Memory/Run-time Performance optimization to transform Json structure

Here is the sample Students json am processing ...
  • 717
-2 votes
1 answer
126 views

Adding 1 million combinations of numbers to a file

The code adds approximately 1,720,000 different combinations of numbers to a file, some_other_file.txt. The numbers range from 2 digits long to 16 digits long. I ...
-1 votes
1 answer
64 views

Optimise python functions for speed

Any one can help me optimise those three functions? I did profiling and timing of my original python file and found that most calls and time duration was because of those three functions. The three ...
4 votes
0 answers
84 views

Reduce size of minesweeper program to fit in qr code

I saw a guy who fit snake in a qr code and I wanted to do the same thing but with minesweeper. The maximum amount of data a qr code can hold is 3kb. My c program, without any compiler magic, takes up ...
3 votes
1 answer
97 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 ...
5 votes
1 answer
75 views

Improving efficiency of download code

I'm in the process of reviewing some old code released by an old colleague. We have a cronjob that executes once in an hour to download some thumbnails: the paths to the thumbnails are stored in a ...
10 votes
3 answers
2k views

Compression Library for C using Huffman Coding

This is an update to a question I posed nearly two years ago about my implementation of Huffman Coding which I had written in C. Since then I have had time to grow as a programmer and have managed to ...
  • 1,360

1
2 3 4 5