memory-management

Rails design doubt: Should/could I load the whole dictionary/table into memory?

I am a newbie working in a simple Rails app that translates a document (long string) from a language to another. The dictionary is a table of terms (a string regexp to find and substitute, and a block that ouputs a substituting string). The table is 1 million records long. Each request is a document that wants to be translated. In a fir...

Is following scenario called memory-leak in java? Is it not Garbage Collected?

If any object variable is still pointing to some object which is of no use, then JVM will not garbage collect that object and object will remain in memory creating memory leak In the above scenario there is possibility of memory leak.. Why is it not Garbage Collected? Can anybody elaborate on it? ...

High rate data stream and memory deficiency

I have a program that accumulates traffic from network interface in 800 Mb/s. This program is developed by Delphi, also in 32bit platform(Delphi does not support 64bit architecture). I'm writing received date on the memory(RAM) and after a while (unknown and depends on received data), write a block of received data (unknown size and dep...

Interpreted languages with manual memory management?

Which interpreted languages pointer-free languages (IE: Python, Java, Perl, PHP, Ruby, Javascript, etc) have manual memory management? I don't recall ever hearing of one. Isn't the major concern about interpreted languages the non-deterministic delays (or space complexity when there isn't enough delay) of garbage collection? So why not ...

Is time comes to not worry about memory

About a year ago we are developed for internal use inprocess MOLAP engine that perform aggregation of a large amount of data. We using it only as a part of our platform because we was sure that such a system without custom memory alocation, paging etc is not viable solution, but some time ago Microsoft published beta version of PowerPivo...

Out Of Memory exception on System.Drawing in a Windows Service

Hi, I am getting in out of memory exception while using system.drawing intensively in my windows service. here is a part of my code: FileStream fs = new FileStream(ImagePath, FileMode.Open, FileAccess.Read); img = (Image)Image.FromStream(fs).Clone(); The exception is not only raised in this point, it is also raised in other points so...

Can I new[], then cast the pointer, then delete[] safely with built-in types in C++?

In my code I have effectively the following: wchar_t* buffer = new wchar_t[size]; // bonus irrelevant code here delete[] reinterpret_cast<char*>( buffer ); Types in question are all built-in and so they have trivial destructors. In VC++ the code above works allright - new[] just allocates memory, then delete[] just frees it. Is it ac...

How to find a java memory leak

I have a problem with a Java memory leak, which for some reason does not show up in my profiler (Yourkit). When I run my Java application (A server with some threads for listening, sending and processing data) it seems that every time I get a new connection and this connection is removed some memory is not cleaned up. At least, this is w...

Performance counters for current threads

Hi, I am building a .NET windows service which is using an unmanaged C++ dll. both of my service and the c++ dll are using multi threading. I am running out of memory after some time (hours) while processing. I tried to measure the number of threads using "Performance counters" and I monitors the following values: # of current logical T...

Process sizes and differences in behaviour on 32bit vs. 64bit Windows versions

I am investigating a strange problem with my application, where the behaviour is different on 2 versions of Windows: Windows XP (32-bit) Windows Server 2008 (64-bit) My findings are as follows. Windows XP (32-bit) When running my test scenario, the XML parser fails at a certain point during the parsing of a very large configuration...

functions memory management C++

hi everyone, i have a little bit lame question, but it's time i have this finally clear. consider regular function with some parameters and a return type. My questions are: are there always made some copies of parameters? i mean even if the function expects reference or pointer as parameter, there are actually new references/pointers ...

How can I check whether an object reference is still valid?

I have an issues where I am trying to determine if a reference to an object is valid. But it seems to be returning strange results. procedure TForm1.Button1Click(Sender: TObject); var form1 : TForm; ref2 : TControl; begin form1 := TForm.Create(nil); form1.Name := 'CustomForm'; form1.Parent := self; //Main Form form1.Sh...

Efficiently allocating many short-lived small objects

I've got a small class (16 bytes on a 32bit system) which I need to dynamically allocate. In most cases the life-time of any given instance is very short. Some instances may also be passed across thread boundaries. Having done some profiling, I found that my program appears to be spending more time allocating and deallocating the things...

Delphi - How to free an object that belongs to 2 (or more) Lists

Hi all, In the project I am working on, there are cases where more than one TList objects contain the same item object. Essentially, there is a master list which contains all the item objects, then smaller lists that contain only a subset of all the items. The items are the same however, not a copy. Where the problem arises is during ...

c# question - is there a tool to identify where I should/can use a "using" statement to ensure resources are closed?

c# question - is there a tool to identify where I should/can use a "using" statement to ensure resources are closed? (to avoid memory leaks etc) Including both the cases that: a) there are resources not been closed and b) syntax is using a try-catch-finally and identies this could be changed to a using Thanks ...

What happens if I call GlobalLock(), then fail to call GlobalUnlock()?

In Win32 in order to paste data into the clipboard I have to call GlobalAlloc(), then GlobalLock() to obtain a pointer, then copy data, then call GlobalUnlock() and SetClipboardData(). If the code is in C++ an exception might be thrown between calls to GlobalLock() and GlobalUnlock() and if I don't take care of this GlobalUnlock() will ...

Objective-C memory management (alloc and autorelease)

When you allocate and initialize and object, and then want to return that object, how are you supposed to return it? I have the following code: NSXMLDocument* fmdoc = [[NSXMLDocument alloc] initWithContentsOfURL:trackInfoUrl options:NSXMLDocumentTidyXML error:&err]; return [fmdoc autorelease]; Is this correct? ...

Objective-C memory management regarding big loops

I have a really large loop in my program, and I use a lot of temporary and instance variables. As my loop keeps running, the program uses up more and more memory until it crashes. Can I get some advice on how to do correct memory management in this situation? My main question is, why is the following code wrong? Here is the code that is...

C++ Controlling destructor order for global objects

I've got a class (A) that accesses (indirectly via a static method) a static variable (an STL container) in another class (B) in its constructor and destructor. A objects may be global, global constants, static members of another class, stored in other classes (which may themselves have global or static instances) or basically anywhere ...

Objective-C NSMutableArray releasing / destruction

The following code in my function (run in a loop) is causing my program to use more and more memory until it crashes. What am I doing wrong? - (void) processTrackValues:(NSMutableArray*) tags { NSImage* trackArt = [tags objectAtIndex:5]; NSMutableArray* tempArtArray = [[NSMutableArray alloc] init]; [tempArtArray addObj...