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
11
votes
1answer
107 views

Python genetic sequence visualizer

I'm a beginner at python, and this is my first major project. Inspired by this reddit post, I wrote a program that accepts a DNA sequence (in a FASTA file format) and generates a graphical ...
5
votes
2answers
95 views

Transpose tab-delimited table in C

I have looked online for transposing programs, but have found that they have extreme RAM use for large tables. The RAM use is so extreme I can't run most jobs on my laptop. I also have a Perl ...
1
vote
1answer
4k views

Generating a word bigram co-occurrence matrix

I have written a method which is designed to calculate the word co-occurrence matrix in a corpus, such that element(i,j) is the number of times that word i follows word j in the corpus. Here is my ...
4
votes
5answers
2k views

Find The Duplicates in two arrays

Find The Duplicates Given two sorted arrays arr1 and arr2 of passport numbers, implement a function findDuplicates that returns an array of all passport numbers that are both in arr1 and arr2. Note ...
8
votes
1answer
295 views

Calculating the Average Minimum Length of Random Numbers From 0 - 1 that Adds up to Greater Than 1

My Computer Science teacher gave us a task to calculate the average after one billion trials. His exact assignment was this: Consider generating a sequence of random numbers on the interval [0, 1) ...
4
votes
1answer
88 views

Binary/yijing clock in Processing with excessive resource consumption

I've been learning Processing for the last week or two, and I've made a couple of little 'desktop toy' type apps like this one that I'm quite pleased with. However, it just occurred to me today to ...
6
votes
1answer
606 views

Read CSV and use bidirectional BFS to find the shortest connections between actors

I have a really huge file¹ with 17 million records in it. Here is a sample of the file: Actor Movie 1,2 2,2 3,1 4,3 2,3 ...
5
votes
1answer
166 views

C++ class to compute similarity coefficients

I'm a complete beginner in C++. I wrote a class to compute similarity coefficients using Euclidean distance and Pearson coefficients on map data structure. I would ...
3
votes
1answer
344 views

Counting subsets with sum not exceeding some limit

I am facing a variation of a subset sum problem. I have to count the number of subsets with sum less than or equal to some integer(limit). I think the optimal solution for this problem would be the ...
5
votes
0answers
206 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 ...
7
votes
2answers
729 views

The performance of the simulation for an ant's random walk on a 5x5 grid

I have written a simulation in order to solve the 280th problem in Project Euler, and the simulation basically repeat the given experiment 5m times, and for each experiment, writes the ExpNo - #...
2
votes
0answers
569 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 ...
1
vote
1answer
128 views

Implement C++11 multipart sending without copying to a single buffer

I am working on a C++11 project and am migrating the underlying communications library used. The original library allowed sending messages in multiple parts using a ...
1
vote
2answers
208 views

Heap space issue with queue

I need some help with this code which is giving me a heap space issue. I have tried executors too but still I get out of memory issue. The consists of a queue which initially holds an endpoint. The ...
1
vote
0answers
80 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. ...
5
votes
2answers
770 views

Permutation of objects, increase maximum limit

I am using this function to find all permutation of objects of a given length. However, right now, the maximum length I can reach before it throws an "Out of memory exception" is 9 (also, it gets too ...
4
votes
2answers
207 views

Using a radix tree to find case-insensitive matches in large files

I'm using a radix tree library to find case-insensitive matches from several relatively large files (~24 files each on the order ~150MB). My current algorithm requires me to read the chars of an ...
4
votes
2answers
852 views

Memoized Collatz sequence

Here is one of my programs that utilized memoization and array to improve performance and memory usage. The performance seems satisfactory but the memory usage is ridiculous and I can't figure out ...
4
votes
0answers
283 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
3answers
125 views

Associating a string with a derived class

I am using the following code to get a string that is associated with the class of an instance: ...
3
votes
0answers
516 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
4answers
485 views

Finding anagrams in Java (space-optimised)

I've lately been asked in a job interview to program a solution for the well known anagrams problem: given two strings s1 and s2,...
2
votes
0answers
413 views

Partial file encryption with AES

Task is to encrypt part of the file using aes encryption algorithm. I did ...
5
votes
1answer
527 views

Choose random instants in a day with a low memory footprint

I'm looking for a way to plan a list of X events at the start of the day... What I did before: At 02:00 every day, choose X timestamps from "now" to 01:59 the next day. That worked well but ...
7
votes
3answers
522 views

Type-agnostic BubbleSort in C

I'm trying out different sorting algorithms for learning purposes, here I'm doing a "type-agnostic" bubbleaort. I modeled the function signature after the standard library's ...
1
vote
0answers
657 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 ...
1
vote
0answers
62 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 <...
5
votes
1answer
2k views

C++11 : simple Tree implementation

I have created a C++11 implementation of a simple Tree for an online code challenge, I'd like to know how to improve it and how to make my code use less memory : ...
3
votes
0answers
789 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 ...
3
votes
0answers
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 ...
3
votes
2answers
437 views

Sampling words from randomly chosen text files

I've developed a script to randomly select 50 elements from a list of .txt files. This process is repeated 100 times. The script joins the randomly selected text files to one long string and then ...
2
votes
1answer
225 views

The BFS approach to the SmartWordToy challenge

I'm currently working on solving the SmartWordToy TopCoder problem: The toy company "I Can't Believe It Works!" has hired you to help develop educational toys. ...
6
votes
0answers
415 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 ...
4
votes
1answer
6k views

Improving gzip function for huge files

I have created a python system that runs Linux core files through the crash debugger with some python extensions. This all works fine but one bit of is problematic. These files are send to the ...
1
vote
1answer
126 views

Displaying weather data from an Arduino

Please review my code, for performance and readability. 3 issues I am facing are Uncaught Exception : out of memory (in firefox) randomly Failed to load resource: The request timed out. Even if the ...
1
vote
0answers
386 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 ...
5
votes
1answer
2k views

WAVE to FLAC encoder in C

This is a .wav to .flac encoder that I wrote a little while ago. The only method that is really called is ...
1
vote
1answer
647 views

Removing duplicate letters from list of words with Python and List Comprehensions

I'm guessing this has quadratic time complexity, \$O(n^2)\$, and \$O(2n)\$ for memory complexity. I wonder if I can do something within the list comprehension to just ...
0
votes
0answers
216 views

DataTable extension methods and proper disposing of unneeded resources

I've build two extension methods, that allows me to show DataTable inside window. Below is my code: ...
4
votes
1answer
170 views

Memory efficient Log Parser

I wrote this together for a test I'm doing that parses the Heroku access log. What I'm mainly interested is if this code follow common best practices and if there are any improvements I can make in ...
2
votes
2answers
1k views

Project Euler #15 in Python

I've wrote the code for Project Euler #15 and it runs amazingly fast. I know I can write it using binomials but I wanted to calculate by brute force as if I do not know Binomials. But I think it must ...
0
votes
2answers
156 views

Calculating shortest possible route between two given nodes

I recently came across this problem: Heroes in Indian movies are capable of superhuman feats. For example, they can jump between buildings, jump onto and from running trains, catch bullets with ...
3
votes
2answers
178 views

Calculating Pi with Android

I'm kind of new to Java but I am writing an Android app. Right now I'm working on an async task to calculate Pi but when I run it the memory usage increases alarmingly (+5MB per second). This one ...
2
votes
1answer
461 views

Basic memory pool, alignment, thread safety

Mainly for practicing purposes, I'm trying to implement a simple, yet efficient memory pool. It's basically a linked list that is able to grow, with fixed sized members. Each node has a flag if it's ...
1
vote
0answers
412 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 ...
2
votes
2answers
323 views

Creating monthly files from an annual file

I am interested in learning a more succinct (or better performing) way of writing the following working code. I just figured it out but it is pretty messy. This program takes a file full of daily ...
3
votes
3answers
441 views

Calculating number of unharmed leaves

I recently came across this problem that asks you to print the number of leaves not eaten by the caterpillars: As we all know caterpillars love to eat leaves. Usually, a caterpillar sits on leaf, ...
1
vote
2answers
1k views

Finding the longest palindrome from the given string

Recently I came across this problem which instructs me to find the longest substring which is a palindrome: As we all know, a palindrome is a word that equals its reverse. Here are some examples ...
4
votes
1answer
2k views

Find files with content matching regex

Today I wanted to find a program that I wrote a while ago. I knew that it contained a certain regex, but I couldn't for the life of me remember the file name I saved it under. I knew I could use ...
4
votes
1answer
1k views

Pulling data from API, Allowed memory exhausted

I'm working on a project where I pull data (JSON) from an API. I would like to manipulate this data and store this as useful information in my DB (MySQL). My code is working if I would like to make, ...