RazerWriter Posted July 13, 2003 Posted July 13, 2003 It's wierd, whenever I try to close my window (that's running on dx9), the windows closes, but the program is still in run mode, then when I try to end it manually, it freezes for a long time and then closes. Can anyone tell why it's doing this? Quote
*Experts* Volte Posted July 13, 2003 *Experts* Posted July 13, 2003 Is there a game loop you are inside? For example:'declare bContinue form-wide Do Until bContinue 'rendering code and game code here LoopIf you try to close the game without ending the loop, it will still be in run mode. You need to make sure you set bContinue = True to close the program. Quote
RazerWriter Posted July 13, 2003 Author Posted July 13, 2003 I have an array of vertices. The program only does this when I load up the vertices and create them. Strange, the memory count nearly quadruples after I load them. Quote
*Experts* Nerseus Posted July 14, 2003 *Experts* Posted July 14, 2003 Could you post the project so we can take a look? -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
RazerWriter Posted July 14, 2003 Author Posted July 14, 2003 If you want the source, pm me and I will give you the link. Quote
*Experts* Volte Posted July 14, 2003 *Experts* Posted July 14, 2003 You can attach the project to posts by using the attachment box on the New Reply screen. Quote
RazerWriter Posted July 14, 2003 Author Posted July 14, 2003 Yes VolteFace, I know how this forum works, thank you. I just don't want the code to get into the wrong hands if you know what I mean. Quote
Lance Posted July 25, 2003 Posted July 25, 2003 i had this problem too. make sure you call dispose on everything...esp the vb/ib's. it should fix things right up. (i bet you're making new vb's every frame huh?) Quote
RazerWriter Posted July 25, 2003 Author Posted July 25, 2003 Problem solved I got it to work.. what I did was load and create all the objects before I load anything else (like the form). Then, only dispose them at the end of the program. This way, I don't have to initialize and destroy objects constantly. The only thing that I load and unload during the program are the textures to free memory, everything else gets initialized right away. Another question... Should I use this method: Object.Dispose Object = nothing are they the same? Quote
AndreRyan Posted July 26, 2003 Posted July 26, 2003 Object.Dispose destroys the object and marks it for collection I'm not exactly sure what Object = Nothing does, but I think it just pushes the object out without Disposing so its only marked for collection when it goes out of scope You should just use .Dispose Quote .Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Lance Posted July 26, 2003 Posted July 26, 2003 (edited) I asked Tom Miller about this today. He says it doesn't automatically get cleaned up by the garbage collector when it goes out of scope because when it's created, it gets hooked to it's device's disposing event. So when it goes out of scope, the GC still counts a reference to it. What you see when you exit your program is your device cleaning up all those resources that you've built up. It doesn't really hang, it just takes it's time. Fortunately, the summer beta added a toggle to tell the device to use weak references instead. Also new to the summer beta are resources that actually implement IDispose, so you have put them in using blocks now. (yay!) Lance Edited July 26, 2003 by Lance Quote
reanjr Posted July 26, 2003 Posted July 26, 2003 = Nothing Happens when a variable goes out of scope Used for quicker Garbage Collecting and for program logic to check e.g. you write a Division function because you do not want it to throw division by 0 errors. Instead, return Nothing, indicating the value is indeterminate -or- use obj=Nothing to free up memory for long running functions. If func() loads ten large bitmaps, gets data from them, then starts a recursive algorithm on the data that takes 90 seconds, you can set those bitmaps to Nothing to free up memory, which otherwise wouldn't happen for 90 seconds Object.Dispose Exposed by IDisposable Used for Class that holds references to unmanaged data (i.e. file handle). These references can't be freed by the Garbage Collector ; .NET doesn't knows about them. When the Object is freed, the data remains referenced and will stay. You can no longer access your Class instance (it is Nothing), so it is impossible to know where the data is to free it. This causes Leaks. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.