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

Possible memory leak in Python script which plays sound while holding down a button

I am working with Raspberry Pi and I made this little Python script that plays sound while you hold down a button and it keeps repeating while you hold it. and no matter when you stopped holding ...
1
vote
3answers
72 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 ...
7
votes
1answer
326 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
1answer
39 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). ...
3
votes
1answer
74 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 ...
0
votes
0answers
22 views

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

Consider my following code from the Tribonacci sequence kata. ...
2
votes
1answer
108 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
0answers
80 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 ...
1
vote
0answers
63 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. ...
5
votes
6answers
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 ...
6
votes
1answer
112 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
1answer
55 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
1answer
53 views

R code optimization

I have about 977 obs in top500Stocks which contains name of 977 stocks. ...
2
votes
1answer
137 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++. ...
2
votes
0answers
42 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
2answers
107 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 ...
5
votes
1answer
95 views

How to speed up scraping large amounts of data with Python

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

Memcpy function optimzation

Here is my memcpy algorithm I've been working on: ...
0
votes
1answer
67 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 ...
2
votes
3answers
125 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
1answer
201 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
2answers
121 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 ...
1
vote
0answers
25 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 ...
2
votes
0answers
97 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. ...
4
votes
1answer
78 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 ...
0
votes
1answer
83 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
2answers
147 views

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

Here is the sample Students json am processing ...
-2
votes
1answer
110 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
1answer
59 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
0answers
78 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
1answer
86 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
1answer
68 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
3answers
1k 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 ...
3
votes
3answers
146 views

Optimize Memory Java String Array

I was trying to solve one programming challenge : First input is a list of connections which is made of pair of IPv4 address. Each IP has its own state which starts with false, each connection also ...
2
votes
1answer
47 views

TypeScript: Object Duplication impact on performance

For a library I am working on, I have created a class WatchableCollection which will monitor an endpoint of an API for updates and issue events (...
3
votes
2answers
2k views

Hackerrank problem: Climbing the Leaderboard (Java)

I am solving the following Hackerrank problem: Climbing the Leaderboard. The problem statement: Alice is playing an arcade game and wants to climb to the top of the leaderboard and wants to track her ...
3
votes
2answers
64 views

Using deque for composing a string from 2 alternating stacks

We have 2 strings, say "JACK" and "DANIELS". We create two stacks from these strings, and then loop over them comparing first elements: whichever of the 2 goes first in lexicographic order gets popped ...
2
votes
0answers
503 views

C# class to dump the memory of a process in several formats

I made this because I couldn't find any good C# classes/libraries that allow you to dump the contents of a process' memory into a file or a byte array. I haven't tested this on 32 bit systems but it ...
1
vote
2answers
95 views

which for loop has better performance in javascript? [closed]

I can't find out which loop is better performance than another, if you know help me. I try about loops in js and performance in this site and this is code snippet, you can run and check. ...
1
vote
0answers
40 views

How does one increase effeciency of the memory functions of CUDA code?

I have the default code snippet that comes with the nvidia nsight eclipse V10.2, but I've modified it to do some profiling: ...
4
votes
3answers
131 views

How can I optimize my code that uses nested for loops?

I am working to solve a problem where I need to determine if a Point lies on a line connecting two other Points. For example, ...
2
votes
1answer
51 views

Restructuring loop logic and its effect on allocations

I came across in a code base # TODO this seems very clumsy to duplicate the loop code like this? so I figured I'd give it a shot as a learning exercise. I'd like ...
4
votes
2answers
105 views

SPOJ - ADDREV (Adding Reversed Numbers)

https://www.spoj.com/problems/ADDREV/ My answer to ADDREV challenge on SPOJ (link to the problem given above), written in JAVA, was accepted. However, the timing was 1.23 and memory used was 82M, ...
1
vote
1answer
86 views

Find number of unique paths to reach opposite grid corner

I have m x n grid. m >= 1 ; n >= 1 I have item in the top-left corner and need to reach bottom-right corner of the grid. Item can only move either down or right. I need to find possible unique ...
3
votes
1answer
63 views

Implementation of Luhn Check Algorithm

I am beginner a 1st year cs student. I am taking CS50 and I completed the first week problem of implementing Luhn Check algorithm. Though my solution works I feel it's very sloppy and not efficient. ...
2
votes
1answer
104 views

Preserving principle of locality while performing memory allocation

In order to implement an efficient AST visitor preserving the principle of locality, I implemented some reference counting mechanism in C++ with the following set of features: All the newly allocated ...
3
votes
0answers
43 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 ...
4
votes
1answer
64 views

Reverse String : Recursion

We have to reverse char[] using recursion. Input: ["H","a","n","n","a","h"] Output: ...
1
vote
0answers
86 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 ...
2
votes
1answer
81 views

Permutation code in C

I am pretty new to competitive programming. It took me almost 3 hours to make this, initially I started with 4 for loops and then to make it scalable for sizes bigger than 4, I decided to turn this ...

1
2 3 4 5