2
голосов
7ответов
524 просмотров

Is it necessary to free the memory in .Net as if in VB6?

I was reading about the Form's events in VB6 such as "Unload" "QueryUnload" and "Terminate", and about the "End" statement: https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-5533338.html http://visualbasic.freetutes.com/learn-vb6-advanced/lesson6/p5.html I used...

11
голосов
3ответов
1626 просмотров

C#: In what cases should you null out references?

The CLR Profiler can also reveal which methods allocate more storage than you expected, and can uncover cases where you inadvertently keep references to useless object graphs that otherwise could be reclaimed by GC. (A common problem design pattern is a software cache or lookup table of items ...

8
голосов
4ответов
6250 просмотров

Does using a delegate create garbage

I'm working on a game for the xbox360, using XNA. On the Xbox the garbage collector performs rather badly compared to the one on a PC, so keeping garbage generated to a minimum is vital for a smoothly performing game. I remember reading once that calling a delegate creates garbage, but now for t...

52
голосов
6ответов
46571 просмотров

Java garbage collector - When does it collect?

What is it that determines when the garbage collector actually collects? Does it happen after a certain time or after a certain amount of memory have been used up? Or are there other factors?

-1
голосов
1ответов
821 просмотров

Tutorial about objective-c garbage collection

I would like to understand garbage collection in objective-c. I know how to work with memory in C-like languages and in languages where I don't care about memory. But I don't understand when to use autorelease, retain, dealloc and everything else, so I get errors and memory leaks. Could someone...

5
голосов
3ответов
1847 просмотров

Clearing a double-linked list

I have a double linked list (queue) I have made on my own. I am wondering, to clear the linked list, is it enough to simply remove the head and tail references? E.g public void Clear() { Head = null; Tail = null; } I am imaging a domino effect, but I am having a hard time testing it...

1
голосов
1ответов
2359 просмотров

Need help reducing the Commit size of my VB.NET Application

I have an application which I've developed which queries Active Directory information and stores about 15 properties into a Datatable which is kept in memory. I need to decrease the amount of "Commit" memory it is setting aside. The application stays active in the system tray and allows for qui...

148
голосов
13ответов
200151 просмотров

How to free memory in Java?

Is there a way to free memory in Java, similar to C's free() function? Or is setting the object to null and relying on GC the only option?

0
голосов
2ответов
1278 просмотров

Objective C - NSImageView, NSImage, NSBitmapImage rep object lifecycle?

I've built a video viewer that is a Safari plugin that displays video from networked devices. The viewer reads bitmap images, prepares them, and sets them on the NSImageView object as follows: NSBitmapImage *bmImg = [[NSBitmapImage alloc] initWithBitmapDataPlanes: . . .] NSImage *img = [[NSImag...

0
голосов
1ответов
406 просмотров

ORO (One Reference Only) Memory Management

What do you think about the concept of using ORO instead of traditional Garbage Collecting? It doesn't seem to be widely adopted, and is more or less argumentative, but it can provide these benefits as I know: Synchronous execution of code: your program will always take known amoun of time to e...

2
голосов
2ответов
473 просмотров

Memory issue in C#, normal use if dll is called by .Net app but astronomical if dll called from legacy app

I have created dll in C# 3.5 which does some memory intensive matrix calculations where matrices get created and disposed a lot. Everything works fine if dll is called from .Net app but if it is called from C++ created app memory usage just climbs until the function that uses matrices is done. I ...

11
голосов
4ответов
2179 просмотров

OutOfMemory, but no gcroots for many objects

We are developing a rather large Windows Forms application. In several customers' computers it often crashes with OutOfMemory exception. After obtaining full memory dump of the application moments after the exception (clrdump invoked from UnhandledException handler) I analyzed it with ".NET Memor...

7
голосов
5ответов
464 просмотров

How to handle disposable objects we don't have a reference to?

If you have a brush and pen as in: Brush b = new SolidBrush(color); Pen p = new Pen(b); and dispose them like so: b.Dispose(); p.Dispose(); How would you dispose it if it was: Pen p = CreatePenFromColor(color) which would create the brush and pen for you? I can't dispose the brush inside t...

2
голосов
4ответов
2952 просмотров

Exceptions during Finalize(): what methodology are you using to detect garbage collector-time exceptions?

I am developing a pretty extensive system in .NET, which involves a lot of system programming. Most time, I'm using the IDisposable pattern to handle resource disposal, but sometimes this isn't applicable (or left out by mistake) and resource gets destroyed during Finalize(). This might happen in...

7
голосов
7ответов
1257 просмотров

GC start and stop events

Isn't it possible to get an event when the GC begins? I want to time each individual GC so I can see if pauses in my server are due to GC or something else. The GC pauses all .NET threads while running, right? (Except the thread that it runs on, of course). How about unmanaged threads? Thanks!

3
голосов
3ответов
246 просмотров

On switching out garbage collectors in Java

Recently I heard Kirk Pepperdine speak about changing garbage collectors for better performance -- but what exactly does that mean and what makes one garbage collector better or different than the other?

1
голосов
3ответов
185 просмотров

Clearing up large fields from memory in long lived objects

.NET 3.5, I've got some classes which stores up to 1MB of strings. Even though I need the object for a really long time I don't need to store the string for a long time. How can I truly remove the string from memory without disposing the parent object. Is it a good practice to use "myString = ...

2
голосов
6ответов
1414 просмотров

I heard that Python has automated "garbage collection" , but C++ does not. What does that mean?

I heard that Python has automated "garbage collection" , but C++ does not. What does that mean?

4
голосов
2ответов
419 просмотров

When happens to value types when they're removed from a collection?

Suppose I have some simple struct like this: public struct WeightedInt { public int value; public double weight; } Then let's say I have a collection of instances of this structure: List<WeightedInt> weightedInts = new List<WeightedInt>(); As I understand value types ver...

22
голосов
3ответов
6853 просмотров

Javascript memory management pitfalls?

I know that Javascript has a garbage collector. Therefor, using delete remove only a reference to the object, and when there is no more reference to this object, it is deleted by the GC. Javascript is tricky, with the closures, the fuzzy name space and the prototype inheritance, it's not always ...

0
голосов
1ответов
365 просмотров

Do event handlers stop garbage collection if the hanlder is in a seperate assembly?

If I have a class declared in assembly A, and am listening to it in assembly B, will this prevent garbage collection. Its a common situation, such as the one where you are listening to a property of an object in the business model from the ui. i saw this question which talks about event listener...

14
голосов
5ответов
8782 просмотров

What's a good library to do computational geometry (like CGAL) in a garbage-collected language?

I need a library to handle computational geometry in a project, especially boolean operations, but just about every feature is useful. The best library I can find for this is CGAL, but this is the sort of project I would hesitate to make without garbage collection. What language/library pairs c...

9
голосов
1ответов
374 просмотров

Guidance on optimising Python runtime for embedded systems with low system resources

My team is incorporating the Python 2.4.4 runtime into our project in order to leverage some externally developed functionality. Our platform has a 450Mhz SH4 application core and limited memory for use by the Python runtime and application. We have ported Python, but initial testing has high...

-1
голосов
1ответов
527 просмотров

Event subscription to a static instance. How to ensure GC

I'm fixing a User control component using the .NET 1.1 framework. There are many instances of this user control referencing a singleton wrapping a COM resource. They subscribe to events from this resource. I suspect that the reason why we are having a degrading performance is because the sing...

15
голосов
9ответов
5855 просмотров

Why are weak pointers useful?

I've been reading up on garbage collection looking for features to include in my programming language and I came across "weak pointers". From here: Weak pointers are like pointers, except that references from weak pointers do not prevent garbage collection, and weak pointers must hav...

228
голосов
22ответов
332394 просмотров

How to force garbage collection in Java?

Is it possible to force garbage collection in Java, even if it is tricky to do? I know about System.gc(); and Runtime.gc(); but they only suggest to do GC. How can I force GC?

12
голосов
6ответов
14287 просмотров

C# - Are objects immediately destroyed when going out of scope?

Can I trust that an object is destroyed and its destructor is called immediately when it goes out of scope in C#? I figure it should since many common coding practices (e.g. transaction objects) rely on this behaviour, but I'm not very used to working with garbage collection and have little insi...

32
голосов
4ответов
57588 просмотров

for line in open(filename)

I frequently see python code similar to for line in open(filename): do_something(line) When does filename get closed with this code? Would it be better to write with open(filename) as f: for line in f.readlines(): do_something(line)

2
голосов
4ответов
527 просмотров

what happens to a python object when you throw an exception from it

My class contains a socket that connects to a server. Some of the methods of the class can throw an exception. The script I'm running contains an outer loop that catches the exception, logs an error, and creates a new class instance that tries to reconnect to the server. Problem is that the serv...

4
голосов
3ответов
656 просмотров

How to pause Garbage Collection in .NET?

I'm running some performance tests on some .NET code that processes lots of data. I want some tests that ensure the garbage collector isn't influencing my results. How do I temporarily pause the garbage collector?