Questions tagged [memory-management]

Memory management is the act of managing computer memory by allocating portions of memory to programs as well as freeing memory so that it can be re-used.

Filter by
Sorted by
Tagged with
3
votes
2answers
317 views

Objective-C retain / release snippet

Here are some snippets I coded and I would like some feedback on my way of handling this: I have a utility class, as a singleton, that provides me with a method named ...
8
votes
2answers
5k views

A blocking buffer manager to provide segments of a byte array

Since asynchronous operations (like Socket's Begin*-End* pairs and ...
8
votes
4answers
5k views

Code works but memory usage is erratic

I have the following class which is a tool for retrieving MD5 hashes of files that are input into it. They can potentially be very large files and I require cancellation and progress report, hence why ...
3
votes
2answers
219 views

C++: Am I managing memory the right way? [closed]

Also, how would I go about putting my class in another file? Thanks! ...
3
votes
1answer
253 views

Reading a data file for performing a FFT

I'm a bit concerned about function usage. There are so many different libraries/possible ways to do something that I'm not sure if the way I'm working at the moment is reasonable, or what I could ...
4
votes
2answers
460 views

C++ Vector memory management in Game of Life

I'm writing a simulator for Conway's Game of Life (http://en.wikipedia.org/wiki/Conway's_Game_of_Life) in C++ and I'm trying to make the code as idiomatic as possible. The central object is a ...
4
votes
2answers
1k views

Can not clearing a local java.util.Vector cause a memory leak?

In the code below, does not clearing or setting the local variable completed to null create the potential for a memory leak? ...
2
votes
2answers
205 views

Possible leak in heavy app

I built my first long running AJAX heavy app and memory leaks are eating me alive. I don't want to post too much code because it should be my job to fix it all, but I need some help. Does this code ...
-2
votes
1answer
289 views

Zeroing memory on Windows

I need some useful functions that faster than the original. (Original - C++'s functions) For example: ...
6
votes
2answers
10k views

Reversing a linked list by iteration and recursion

From my original question on Stack Overflow: Is my implementation of reversing a linked list correct? I'm a beginner at C and I'd like to know about style, and correctness of the reverse algorithms. ...
6
votes
3answers
370 views

Memory management with password retrieval

Questions: Is this code secure? (I think that it is, but I'm a newbie so I want to be sure.) Is the get_pass function correct with passing the arguments to the <...
1
vote
1answer
2k views

Will this code get cleaned up by the garbage collector?

I have been working on a Backbone.js application, and I am starting to think I am making a huge mistake. I never fully understand garbage collecting, and how exactly some closures prevent it. I just ...
3
votes
1answer
2k views

Java: Find the smallest integer not in the list - Memory Efficiency

This is a fairly popular interview question that I conceptually understand but have never really attempted to implement. In other similar implementations of this in Java I have seen they typically ...
5
votes
2answers
8k views

Min Heap implementation with Dijkstra's algorithm

I am implementing Dijkstra's Algorithm using Min Heap to speed up the code. For a small number of nodes, the code is really running very fast. But for a large number of nodes, my code is throwing ...
1
vote
1answer
982 views

Free memory outside function

Is this going to leak memory or is it ok? Please also let me know if there is something else that I need to pay attention to. ...
1
vote
1answer
212 views

Variable sized type allocation

I have a type that receives serial data over a pipe: struct Packet : Base { // Base is POD, too int foo; char data[]; }; In the context, where I instantiate <...
2
votes
1answer
341 views

Is this a valid usage of structure assignment in C?

Q: Please comment on the usage of structures and structure assignment operations in C I am working on converting a MATLAB program to C using BLAS and LAPACK for linear algebra support. The MATLAB ...
2
votes
2answers
1k views

Read until EOF and realloc as needed

This is a function that reads until EOF and reallocs as it goes. ...
3
votes
2answers
2k views

Tree Node class - deallocation in the destructor

Is my destructor correct? Does it properly deallocate the subtrees? ...
5
votes
1answer
1k views

Simple TCP client - memory issues

Does this snippet take too much memory? How can I let the connection opened with the function connectTo outside the forever loop? ...
2
votes
1answer
326 views

Am I using my data source array correctly?

When I want to make some quick tests for my UITableViewControllers, I usually create an NSArray that holds some dummy data. I would like to know if I'm doing anything wrong here: First in ...
3
votes
1answer
2k views

Space to allocate before sprintf

I just finished chasing a Heisenbug that was entirely my fault. I'd like to avoid it happening again. I have a function which formats a date to a certain preset format. Turns out I was not allocating ...
5
votes
2answers
912 views

Human (imperfect) array (card) shuffle written in C

I've got this humanoid_shuffle I wrote in Python. I've been wanting to learn C so as an exercise I ported it to C. As this is my first venture into C and even the ...
3
votes
1answer
903 views

Memory leak in a scraper [closed]

This is a scraper written in CoffeeScript for NodeJS. It is run in an interval (set to 5 seconds here to dramtically show the leak). Somewhere this code leaks memory. I already tried nulling a few ...
6
votes
1answer
659 views

Memory issues with Find Strings Problem on InterviewStreet

Here is the code I wrote for the problem at http://www.interviewstreet.com/recruit/challenges/solve/view/4e1491425cf10/4efa210eb70ac where we need to to print the substring at a particular index from ...
6
votes
1answer
289 views

Is this a good algorithm for 2D collision, or will it allocate too much memory?

I have a Rectangle class, of which I have 5-6 vectors for each instance. The main vectors are the center and color of the object, while the secondary vectors represent more or less the north, south, ...
4
votes
3answers
758 views

Simple, lightweight deterministic “garbage collection”

I am toying with a simple class to inherit from to manage my dynamic resources. I am fairly new to C++, so my "implementation" might be suboptimal. Suggestions how to improve functionality are welcome....
3
votes
1answer
179 views

Am I managing my memory correctly?

I read that if an object is made using the init it must be released, but if it's something like this ...
6
votes
3answers
833 views

App for allowing the user to type in chemistry formulas using a custom keyboard

Essentially, I am making an app that allows the user to type in chemistry formulas using a custom keyboard. The keyboard will have several keys, for example, "Na", "H", and "O". Pressing them in ...
8
votes
1answer
4k views

Super simple templated memory pool in C++

I have a small program where I have a background thread that plays sound, so it needs to run really fast, but it also needs to do a small amount of memory management. I didn't want to use normal new ...
2
votes
1answer
394 views

Runge-Kutta 2nd order of differential equations

Could I improve this somehow (not numerically, just C-wise)? Do I need to allocate the array since I am returning it and not just using it inside the function? ...
11
votes
3answers
1k views

Reusing strings read from I/O

I am working on an application that reads lots of data from the network and puts it in a grid. I noticed that I could save some memory by reusing existing strings instead of always using the new ...
4
votes
2answers
200 views

Array initialization from text string

I have a block of text where several arrays are printed out, with a name and values: VAL1=10 20 30 40 50 VAL2=4 8 15 16 23 42 I have a function that looks for the value name, and sets an ...
7
votes
1answer
716 views

Double-Ended Queue - Have I over-engineered it again?

I'm working on an implementation of the Double-Ended Queue as a Doubly-Linked List (for personal enrichment), and I was wondering if anyone minded taking a look at my Constructor/Destructor and Empty ...
3
votes
1answer
333 views

My program spikes from 100,000K mem to 1,000,000K mem in a matter of minutes in my program in VB.net [closed]

I've created a program that uses System.Graphics to render a simple (small) 2D scene to the screen. The problem is, for some reason, it starts to quickly ...
1
vote
2answers
327 views

NSAutoreleasePool with Json Data

Just need to know if I'm doing something wrong in this code. my app seem work fast now with this code. I just want to if i really understant that ...
5
votes
1answer
221 views

Overloading the new operator

This may be a naive question, but what are the dangers of the following code (allocate more memory in the new operator for the info struct)? ...
3
votes
1answer
1k views

Does this I/O operation caused a memory leak [closed]

My colleague did some code Optimise work. Code below is from a public method of a public class (NOT STATIC CLASS OR METHOD) code before: ...
3
votes
1answer
1k views

Memory leaks in lottery simulator

I'm primarily a C++/Java programmer, but I've recently started using Python at work and decided to write a Lottery Simulator at home. I wrote it to test out different combinations of lottery numbers ...
8
votes
2answers
2k views

BitTorrent peer protocol messages

I'm writing a BitTorrent client. Part of the protocol is an exchange of length-prefixed messages between peers. The forms of these messages are described in the official specification and also in the ...
1
vote
1answer
599 views

Memory Question

Can this part of a view controller subclass be checked for memory leaks. I am not that good at finding leaks. I need this class to be able to be loaded many time over without it crashing due to memory ...
3
votes
0answers
1k views

Integrating SFML and Box2D lib, and a Mass Production Shape Factory [closed]

I've just written two new headers: one that integrates Box2D and SFML by a class called BodyRep which creates/ is a graphic representation of any body, and one that ...
8
votes
1answer
501 views

Use of external memory or a custom allocator

I'm creating a class which uses a custom buffer. I want to offer the possibility to pass an external memory address (for higher interoperability between languages) or (for convenience) to specify a ...
4
votes
2answers
3k views

Allocating memory for a matrix with a single malloc

For an interview, I was asked to write code allocate memory for a rows*cols matrix, using a single malloc(). I want your comments about this code that I wrote: <...
2
votes
2answers
2k views

Subclassing UIButton

I need to subclass UIButton, however the design of UIButton makes this really painful. This is because to create a button you ...

1
7 8 9 10
11