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

42 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7 votes
0 answers
511 views

Kattis problem Amanda Lounges

I wrote this solution to Kattis problem Amanda Lounges in Scala. TL;DR: It's a graph theory problem where I read in a list of edges from stdin and try to compute the minimum number of nodes that ...
user avatar
5 votes
0 answers
223 views

A Java neural network

I have created a neural network in Java, it contains multiple classes. I have uploaded the documentation for the network here: Doxygen, and the full source can be found on Github. Let me start out by ...
user avatar
  • 187
4 votes
1 answer
95 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 ...
user avatar
  • 141
4 votes
0 answers
80 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 ...
user avatar
4 votes
0 answers
666 views

Kadane's algorithms to leetcode "121 Best Time to Buy and Sell Stock"

I employed the conventional Kadane's algorithms to solve a maximum subarray problem in leetcode Best Time to Buy and Sell Stock - LeetCode Description Best Time to Buy and Sell Stock ...
user avatar
  • 603
4 votes
0 answers
440 views

Two solutions to leetcode 127.wordLadder

I am working on Word Ladder - LeetCode Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such ...
user avatar
  • 603
4 votes
0 answers
381 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 ...
user avatar
  • 63
3 votes
0 answers
83 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 ...
user avatar
  • 247
3 votes
0 answers
90 views

Memcpy function optimzation

Here is my memcpy algorithm I've been working on: ...
user avatar
3 votes
0 answers
52 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 ...
user avatar
3 votes
0 answers
58 views

Batch normalization code optimization?

I am trying to implement Deep Quaternion Networks. I was able to implement the batch normalization technique. But it requires a lot of GPU memory. Is there any way I can optimize the code provided ...
user avatar
3 votes
0 answers
66 views

Minimization problem solving and its step limits

I am trying to solve the following minimization problem: $$ \min\lvert\lvert{x}\rvert\rvert_1 + \beta\lvert\lvert{x}\rvert\rvert^2_2 s.t. \sum_{m = 1}^M (y - \lvert{c}^{H} . x\rvert^2)^2 \le \epsilon ...
user avatar
3 votes
0 answers
499 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 ...
user avatar
3 votes
0 answers
604 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 ...
user avatar
  • 588
3 votes
0 answers
937 views

Memory optimization when finding the Cartesian product in Python

My function gets the Cartesian product of a list of lists of tuples. The function is correctly producing the list of lists, but it's a memory hog (and leads to a MemoryError for large data sets, with ...
user avatar
  • 131
3 votes
0 answers
29 views

URLEncoder implementation Round 2

Half an year ago I posted an implementation of a URL encoder for review. I didn't have any time to work on it until recently, but now looking at my old code with new eyes I saw how unreadable the code ...
user avatar
3 votes
0 answers
52 views

LinkedList of Nodes at each level - optimalization

That's already known problem: to return an array of linked lists that contain values of elements at each level. Eg for tree with depth n there should be n linked lists. I wrote the solution: ...
user avatar
  • 131
2 votes
1 answer
169 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 ...
user avatar
  • 179
2 votes
0 answers
54 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 ...
user avatar
2 votes
0 answers
142 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. ...
user avatar
  • 187
2 votes
0 answers
654 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 ...
user avatar
2 votes
0 answers
251 views

Split a string into valid words

I am trying to solve this LeetCode question: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word ...
user avatar
  • 1,027
2 votes
0 answers
185 views

Initializing Reinforcement Learning Q-Table State Space-Python

The code below is a "World" class method that initializes a Q-Table for use in the SARSA and Q-Learning algorithms. Without going into too much detail, the world has "Pickups" and "Dropoffs" that can ...
user avatar
  • 161
2 votes
0 answers
451 views

Partial file encryption with AES

Task is to encrypt part of the file using aes encryption algorithm. I did ...
user avatar
  • 201
2 votes
0 answers
570 views

"Partial solution" on Code Eval for Clojure FizzBuzz

I'm just getting started on the site CodeEval, and I submitted my first solution today. What I don't understand is why it's marking my (working) answer as only a "partial solution". The site doesn't ...
user avatar
  • 33
1 vote
0 answers
65 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. ...
user avatar
  • 119
1 vote
0 answers
26 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 ...
user avatar
  • 163
1 vote
0 answers
44 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: ...
user avatar
  • 187
1 vote
0 answers
114 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 ...
user avatar
  • 243
1 vote
1 answer
3k views

Clustering using k-medoids

This is the program function code for clustering using k-medoids ...
user avatar
  • 21
1 vote
0 answers
183 views

Golang message bus for a game engine

I wrote a memory bus struct in golang to allow systems to interact with each other without knowing anything about the receiver. This is for a game engine. I know it's not good to write games in ...
user avatar
1 vote
0 answers
21 views

Swapping variable length strings asynchronously with connected microcontroller (Byte-banging)

I have an AT89S52 and an AT89C4051 microcontroller (both in the 8052 family) in which the bit lines of the data bus, one control pin and one status pin are connected together. In code, the data bus is ...
user avatar
1 vote
0 answers
193 views

Applying a filter to a large array with elements that are not regularly spaced

I need to apply a Gaussian filter to a 2D numpy array where the distance between adjacent array elements depends on the row of the array. (Specifically, the data are evenly spaced in latitude and ...
user avatar
  • 111
1 vote
0 answers
108 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. ...
user avatar
1 vote
0 answers
691 views

Sticky notes in a Virtual JDesktop

I made a very practical program consisting of a virtual desktop with a right-click pop-up menu that brings up a button to open a 'stikinote.' These 'stikies' are simply little note-windows where text ...
user avatar
1 vote
0 answers
63 views

Combine similarities

I have a function that is called in several subsets of a matrix containing similarities of pathways or genes or clusters of genes, around 200 millions of unique combinations. To perform that I use <...
user avatar
  • 283
1 vote
0 answers
408 views

Eliminate render block on my bxslider

I am using the bxslider jQuery plugin as a welcome banner with a overlay (see image below for illustration.) This is however causing render block and cannot figure out how I can improve my code to ...
user avatar
1 vote
0 answers
418 views

Scraping websites and saving to MySQL

I have the following piece of code which scrapes websites and saves some information back to MySQL. At the moment is consuming all the memory on my machine every time it runs. I've refactored the ...
user avatar
  • 481
0 votes
1 answer
14 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. ...
user avatar
0 votes
0 answers
23 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'...
user avatar
0 votes
0 answers
29 views

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

I have defined the following function. ...
user avatar
  • 101
0 votes
0 answers
33 views

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

Consider my following code from the Tribonacci sequence kata. ...
user avatar
  • 113