The memory-optimization tag has no usage guidance.
-3
votes
2answers
153 views
RAM overhead on a compression program [closed]
In a program, the one below is attempting to codify into a translation of another file. The output is severely condensed. It works, and once I get it to decompress, then it will win award after award. ...
0
votes
0answers
24 views
Prefetch in ARMv7
I have to implement Khatri Rao product between 2 matrices in C. Mathematically this is a column major access of data and I can not change that. But if I use preload ( PLD instruction in ARMv7 ) to ...
2
votes
2answers
36 views
Find the best path amongst N random points
For an application with a graphical canvas, I want to generate N points. But then I want to link those points, and I want to find the best path through those points.
I wanted to use a dynamic ...
3
votes
0answers
31 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 ...
1
vote
1answer
76 views
Multiple emails and attachments, reusing memory stream
I am generating a pdf form based on user input from an MVC website form. The pdf is genrated using the Foxit .NET SDK, then attached to three separate emails, generated using Postal. It has been ...
3
votes
1answer
564 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 ...
6
votes
3answers
339 views
Rotation of elements in an array
We had to write a program that would perform rotation of elements in an array. The array size was entered by user, so it had to be in a sense, dynamic.
Rotation or Circular Shifting
Initial Array: ...
4
votes
2answers
134 views
Memory Management Code
For a project I had to do a memory management problem without creating any custom classes or templates using the provided pool array and ...
4
votes
2answers
791 views
Binary file validity in C++/C++11: checking a binary header
I have some code for checking a binary header to see if a binary file is meant to be read by a certain program, and I could use some extra eyes to review it.
Assume the following ...
4
votes
1answer
54 views
Construct binary tree from inorder and postorder traversal
The problem is taken from here. The tree is guaranteed not to have duplicate elements.
My questions is, instead of creating new arrays leftInOrder, ...
3
votes
2answers
79 views
Find two numbers that add up to a given total, from a formatted string
The full challenge from codeeval.com can be viewed here.
Input
Your program should accept as its first argument a filename. This file
will contain a comma separated list of sorted numbers ...
3
votes
1answer
43 views
Computing the double Integral using MonteCarlo techniques using Julia
I decided to try and learn Julia for doing scientific computing, and I decided to tackle the problem of finding
$$ \int_{D_{\frac{1}{4}}} x^4 + y^2 dA $$
where \$ D_{\frac{1}{4}} \$ is the part of ...
-1
votes
1answer
136 views
Simplest linked list in C++?
My context was basically to get my linked list implementation in C++ reviewed, since I wrote it from scratch and wanted to make it as simple as possible and learn from suggestions I get. I am trying ...
5
votes
2answers
104 views
Extending Sieve of Eratosthenes beyond a billion - follow-up
Follow up form Extending Sieve of Eratosthenes beyond a billion
Taking suggestions from the comments on the previous post:
Updated Code: This takes about 22 seconds for MAX as \$10^9\$ to reach ...
11
votes
1answer
265 views
Where it all begins: Khronos
This is the main.c file for Khronos, a personal project of mine. This is basically where the whole program is setup, run and then quit. I'll post the short ...
23
votes
4answers
1k views
Extending Sieve of Eratosthenes beyond a billion
For MAX value of 1000000000 (\$10^9\$), it takes about 45 seconds to reach the line where it prints "done". How can I speed this ...
15
votes
1answer
253 views
Bruteforce MD5 Password cracker
I just started learning Go, and I wanted to created a project to learn more about concurrency in go. I heard about Go's lightweight threads, so I wanted to give them a try.
This program uses ...
6
votes
2answers
261 views
Frequency count of single words and word pairs over 20 million tweets
My application needs to read 20-million-line text files and count the word frequencies for one and two words.
For example:
A B A B SSS G D A
One word Frequency
A: 3
B: 2
SSS: 1
G: 1
Two ...
3
votes
1answer
67 views
Tic Tac Toe with Minimax (memory management optimization)
I've made a Tic Tac Toe game with minimax in Javascript. It works but I have to use location.reload(true); to automatically reload the page every time user starts a ...
7
votes
3answers
108 views
Type-agnostic BubbleSort in C
I'm trying out different sorting algorithms for learning purposes, here I'm doing a "type-agnostic" BubbleSort.
I modeled the function signature after the standart ...
4
votes
1answer
217 views
Updating number of votes with a “Like” button
I have a "Like" button in my iOS app that updates the votes every time it's tapped. Just like Facebook, Instagram, ProductHunt, etc.
I have a custom cell where that ...
4
votes
1answer
117 views
Conway's Game of Life
Inspired by this post, I decided to try to implement my own Conway's Game of Life.
I started with a non-warping board:
...
2
votes
1answer
35 views
Compare a sequence with the reference frequency of hexamers
I have written this function (and others similar to that one) But I am not sure I am using references on their full power.
My currently concerns is if I make a huge use of memory. The subroutine ...
2
votes
1answer
139 views
Extract data from large JSON and find frequency of contiguous sub lists
I have been writing some code (see component parts here and here) that:
Takes a very large JSON (15GB gzipped, ~10million records)
Extracts the relevant parts of the JSON into a list of lists
...
3
votes
0answers
95 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, ...
10
votes
2answers
363 views
Unique value finder
For our first assignment in our algorithm class we are suppose to solve several different questions using information from a 2D array. We are also suppose to optimize our code to get more marks on our ...
3
votes
3answers
156 views
Storing and processing large arrays to compute dot products
Problem Statement (from HackerRank)
We have two arrays \$a\$ and \$b\$ of length \$N\$, initially all values equals to
zero. We have \$Q\$ operations. Let's define three types of operations on
...
6
votes
1answer
255 views
Monitoring the recursive growth of a zombie rabbit population
Breeding like rabbits
Write a function answer(str_S) which, given the base-10 string
representation of an integer \$S\$, returns the largest n such that ...
6
votes
1answer
117 views
Sieve of Eratosthenes for prime generation
I was originally going to write this intro as just being the bare-bones "here's my problem, here are some ideas, what do you recommend" format (which I am still going to follow, mind you), but I've ...
8
votes
2answers
130 views
Summation of primes for large inputs
I'm doing a problem from Project Euler to find the sum of all primes under two million.
My code manages to get a pretty good result for small inputs, but when trying inputs like million or two it ...
5
votes
1answer
239 views
CodeEval solutions to find trailing strings
This is a problem in CodeEval, moderate level. The problem is very easy for this level. But I am not able to get more than 60 points for any solution I submit. (Moderate levels highest score is 65 and ...
3
votes
3answers
857 views
Custom ArrayList class
Please review my custom ArrayList class I constructed from scratch and add any suggestions or constructive criticisms. The point of this template class is give the ...
3
votes
2answers
253 views
Memory efficient A* (AStar) Algorithm
I am writing a solved for 15 puzzle game which will find the solution path to any NxN board. For easier boards the algorithm works great solving almost any 3x3 boards, most 4x4 boards, but when I go ...
4
votes
2answers
274 views
Object-oriented JavaScript and Google Maps objects memory management
I have to draw various instances of HeatMaps, Winds and Polylines. Each layer will have one ...
3
votes
3answers
293 views
Web crawler uses lots of memory
I am developing a web crawler application. When I run the program for more than 3 hours, the program runs out of memory. I should run the program for more that 2-3 days non-stop to get the results I ...
6
votes
1answer
91 views
Pool allocator for a scripting language parser
At the moment I'm writing a parser and interpreter for a custom scripting language, to learn more about the basic concepts involved and to get more familiar with tools like ...
11
votes
0answers
243 views
Rust Brainfuck interpreter
I took the code from kostyas benchmarks for the Rust Brainfuck interpreter and tried to optimize it. There is also a discussion on Reddit about the poor performance of Rust in the Benchmark.
Before ...
3
votes
1answer
52 views
Yellow Pages Search
I've written code in Free Pascal based on a contest problem (The contest insists that I have to write with Pascal). It works like charm, but I think it still need some improvements, from memory usage ...
4
votes
5answers
261 views
Permutation of n lists
I have code which gives permutations for 10 lists. The code works fine for small number of lists with small number of values.
Result : It should return all possible permutations. I have to store the ...
2
votes
2answers
87 views
Effecient Use Sieve of Eratosthenes algorithm
Given this as a the Problem Statement
Given two numbers, find the sum of prime numbers between them, both
inclusive.
Input:
The first line contains the number of test cases T. Each ...
5
votes
2answers
264 views
Two-dimensional array, modified one field at a time
Title says it all. I'm basically initializing a two-dimensional array and changing the fields one at a time.
It might be a good idea to do this OO.
A Grid class ...
4
votes
2answers
102 views
Reducing memory usage for FizzBuzz in R
I've been trying all night to get my fizzbuzz to use below 20 MB of RAM but I can't seem to get it much smaller than this.
...
3
votes
1answer
234 views
Number of paths in a grid (lattice) graph
I am trying to solve a variant of the very popular question in which we find the number of distinct valid paths on a directed graph. The graph's nodes make up a m x n lattice (grid), and the edges ...
6
votes
3answers
123 views
SPOJ Adding Reversed Numbers
Recently, I was taking up this challenge and choose my favorite language 'Ruby' to do it.
My following solution got accepted (Gist).
For each test case, I am to reverse two numbers, add them, and ...
3
votes
1answer
89 views
Haskell requires more memory than Python when I read map from file. Why?
I have this simple code in Python:
...
2
votes
1answer
43 views
Candy splitting - lower memory usage needed
I just did CodeChief's candy splitting task here and my code is working even with a lot of test cases and big numbers, but it uses way too much memory. When I checked my submission, it was 1342M, ...
26
votes
5answers
2k views
Recording Audio Continuously in C
As an ongoing little side project of mine, I've been working on recording audio with the C language. You can see a progression of my code by looking at my past two versions (V1.0, V2.0).
I've ...
7
votes
1answer
529 views
Optimizing variable order Markov Chain Implementation
I've created a variable order Markov chain built on top of a tree, but I can't train on datasets >1MB worth of text without running out of memory. I'm sure the tree can be replaced by something else ...