Sample app did not properly cleanup objects ошибка

DxWnd

Window hooker to run fullscreen programs in window and much more…

Status: Beta

Brought to you by:
ghotik

  • Summary

  • Files

  • Reviews

  • Support

  • Home

  • Discussion

Menu

Grand Prix World


Created:

2013-06-07

Updated:

2023-03-01

  • Marc

    Thanks for the ideas.
    Here’s a picture of the desktop, although if you were asking about the problem of painting in on the wrong screen, I’d fixed that issue (see post below) and this now shows the painting inside the proper window frame. Before, the part that should have been within the frame was appearing on the other monitor with the same (or close) 50,50 offset from the top-left of that display. So, the frame was on the main window (right side of this image) while the painting was occuring on the left side.

    The image does show what the race mode looks like now.

    When I tried the two flags (Lock/unlock pitch fix and Width no power of 2) together, the overall graphics of the game were scrambled on stop and I had to kill the program. The Lock/unlock pitch fix flag alone does the same, while the Width no Power of 2 flag alone runs the program but has the same look to the race screen as in the screen shot. The Share ddraw and GDI DC option alone had the same look also.

  • Marc

    OK, got a step closer.

    First, I went back to the file for GPW that comes in the ‘exports’ folder. Left the windows explorer compat settings alone.

    Then, I found a checkbox that says «Don’t Fix Pixel format» under the DirectX tab and checking that makes the ‘paint’ occur inside the window on my main monitor. So, one issue down. The race is still unreadable due to color or other issues, but now I seem to be down to one issue. :)

  • Anonymous

    Hi Marc, this method is worth a try. Go to Direct3D tab > uncheck «Fix ddraw refcount» and check «Return 0 refcount». Does that make the problem less serious?

    If this method not work, please revert to previous setting.

    • Marc

      Pretty much the same. Here’s a pic, but it looks a lot like the one I just cleared ouf of Paint.

      Thumbnail

  • gho

    I saw the picture, and it is strange indeed. This sort of things usualy happens when the program doesn’t manage the graphic in the proper way (that is using the system calls) but takes some shortcut for supposed optimization and generates a full mess.
    Usually the problem disappear if the program works in the exact resolution he supposes to be. Could you try to set the window heigth and width values to 0, 0 in the main DxWnd conf panel and see if the problem disappear?

    • Marc

      OK, here goes then. I’ve got the check box back to «fix ddraw refcount’, and now the H and W set to 0.

      With game programmers, especially from that era, it wouldn’t surprise me at all if they were doing some shortcuts. Strange, a game like this they shouldn’t have had to, but the game is littered with these useless 3d views of race cars on a race track so they may have done something to get more speed in there.

      Had to wait for it, Program was slower to appear. Then had trouble getting the mouse to work. But in the end, it got to the race mode and no difference.

      At this point, I think I’m still close to the shipped settings for GPW, with the changes put in to test and then removed once they don’t work. But, here’s a export of my latest version.

      BTW, I think 800 x 600 was the correct size (values in H and W before I tried 0 and 0). I think I saw that somewhere in display settings while messing around with this in fullscreen (no dxWnd) mode.

      Thanks for the help and for giving it a try. :)

      • gho

        What happens if you temporarily turn off your secondary monitor and configure the desktop accordingly? I’s like to be sure the problem depends on the two monitors, and this test is pretty easy to do.

  • Gianmarco Marzo

    I fear that I need help.
    I tried running GPW through DXWnd following the steps listed in this guide: http://www.gprm.co.uk/forums/index.php?topic=5835.0

    But I alternatively get these two error messages:

    1 «sample app did not clean up objects»
    2 (much more frequent) «%%%sdevices. Try enabling reference rasterizer by running refrast.reg» (a file that does not appear to exist on my computer).
    What’s going on? T_T

  • gho

    Hi Gianmarco,
    I’ m replying from mobile phone but it’ s not easy.
    I’ll be back from holyday twesday, I will make tests then.
    Be patient and happy Easter.

  • Gianmarco Marzo

  • gho

    Here I am. back to work.
    The problem may depend on the version of the game. What I’m actually supporting is a variation of the windows XP port of the game, «gpwxp2.exe», that I can’t even remember how exactly I got it.
    In any case, I would make a clean start putting both you and me in identical conditions: so, please
    1. download the latest DxWnd release v2.03.58,
    2. import the included file «Grand Prix World.dxw» from the DxWnd export folder
    3. unzip the attached version of the game in the game folder.
    4. adjust the dxwnd path field in the configuration so that it points to the gpwxp2.exe file.
    At this point, If it doesn’t work, at least we will share equal conditions.

  • Gianmarco Marzo

    Hello Gho,
    thank you. I will try this out in the afternoon as soon as I am back home and tell you what happens.
    Hope you had pleasant holidays.

  • Gianmarco Marzo

    Okay Gho,
    I tried. I think we’ve made progress. It now says «ensure that game CD is inserted». I suppose I need a no-CD patch of some kind.

    • gho

      Uhm…. no, I think that the problem is that you didn’t install the full gpwxp patch, that likely copies more resourced on hard disk and makes the CD useless. I provided just the exe, but this is not enough.
      Have a look at here: http://www.simracingworld.com/files/download/1086-grand-prix-world-windows-xp-patch/ and follow the instructions. In any case, keep the gpwxp2.exe that I sent you because it may work better with DxWnd (Oh, my! I can’t remember why I patched it!)

  • Gianmarco Marzo

    Hello Gho,
    I downloaded the patch you linked, and kept your exe, but I still get the no cd issue.

    • gho

      What OS are you trying to run it on? I heard that some copy protection schemas were left unsupported by MS recently, and maybe with the protection, also the crack was gone …
      In any case I had it working on WinXP, Win7 and Win10. I left untested only Win8 and 8.1.
      More likely, there must be some error in the installation, but from here I can hardly tell….

       

      Last edit: gho 2016-04-02

  • Gianmarco Marzo

    I am running it under windows 8.1.
    I tried with a pirated version of the game. It’s hard to find a legitimate copy and I would be hesitant to buy it when it may very well not run at all. :/

    • gho

      I never had the (mis)fortune to verify this, but the general opinion on Win8.1 is not very good, since it gained on the field the nickname of «Game killer»!
      You should have a proposal from MS for a free upgrade to Win10, and even if you don’t, there should be a way to di that for free. My personal suggestion is to migrate to Win10: I also was a bit reluctant, but then I migrated directly from Win7 to Win10 in a single step and it was absolutely ok: you loose nothing (as far as I can tell) and you gain some disk space (strange, but true), a more efficient OS and a better back-compatibility with everything, including an integrated support to emulate 8 or 16 bit color depth in a window (they must have copied something from DxWnd, I dare say…).
      In any case, I’m afraid I can hardly support you on 8.1, since I don’t have it. The only final attempt could be to try the last DxWnd beta that I updloaded a few hours ago: that manages much better some latest Window versions.

  • Gianmarco Marzo

    Thank you gho, you have been very kind and I sincerely appreciate that.
    The upgrade to Windows 10 sounds nice. I will consider it, first I want to verify what the web says about the other games I play often running under 10, but since they’re mostly recent I don’t think it’s going to be a problem.
    I will come back to you as soon as I have upgraded to 10 and let’s see if that fixes things.

    • gho

      Release v2.03.60 fixed many problems about ddraw method hooking, that has become more and more selective from WinXP up to Win10. If you like, you may also try this last version, there’s a slight possibility of improvement.

  • Veedub

    Hey Gho, the OP back again :)

    For future tests, can you please test Grand Prix World with DxWnd and gpw103b.exe? Basically, while gpwxp.exe was repackaged by the developer to work with Windows XP, it isnt the latest official version of the game. The latest official version is gpwv101b (packaged for Win98), and I managed to patch out the WinXP bugs and get it working with Windows XP eventually (creating the unofficial gpwv103b.exe). So as a community, we want to use gpw103b going forward where possible.

    You will need to install gpwv101b first, and then apply gpwv103b (which is also a no-cd exe).
    gpwv101b: http://www.edwardgrabowski.com/downloads/gpwv1.zip
    gpwv103b: http://s000.tinyupload.com/index.php?file_id=66902834389965582469

    Of course for GPW to run on any system, you should set compatibility mode on the gpwxxxx.exe file to Windows 98 to get past the game freezing at the gold FIA logo.

    I’m hoping you can help us with the following problem a user has raised to my attention:

    • Unfortunately the 103b patch doesn’t run on Windows 10 but apparently gpwxp2.exe does
    • The same error messages that came up in that Sourceforge thread appear —
    • ‘Sample App Did Not Properly Clean Up Objects’ if you use XP Compatibility mode and
    • ‘Try enabling the reference rasterizer by executing EnableRefRast.reg’ if you use Windows98 compatibility mode.

    I suspect these errors relate to when the game initialises and tests the hardware/software graphics capabilities. As it is Windows 10, I have very little knowledge on this issue but I’m hoping you may understand what is causing these checks to fail or how to bypass them. Apparently the gpwxp2.exe that you created at the start of the thread does seem to work with Windows 10, so it may just be possible to get gpw103b.exe working as well. I did a binary diff on gpwxp.exe, and your exes gpwxp2.exe and gpwxp3.exe to note your changes and will see if I can carry those changes across to gpwv103b.exe (I’ll have to fire up idapro, and cross reference the code) but I suspect there may be more issues to solve. The two versions (gpw101b.exe and gpwxp.exe) have quite different disassembly layouts but the same start up logic.

    Thank you for your efforts so far, any help appreciated. I’ll let you know if I make any discoveries, once I get my own Win10 box up and running, hopefully one day soon.

    Also, not DxWnd related but it is graphics related, can anyone/graphics experts explain this issue with flickering graphics? From the ~3:30 mark in the video, the UI starts to flicker. This is when playing the game normally at full screen on any system/OS. Some system configurations cause the flicker, others work perfectly fine. Our suspicions are that its graphics hardware/driver related (possibly nvidia only). I wonder if it is GDI vs DirectX interference or something or clockspeed, as I notice the system that the game flickers on has unhelpfully super responsive button clicks?

    Youtube video: https://www.youtube.com/watch?v=0glTWBjZHXk&t=3m30s
    Google suggestion: http://community.pcgamingwiki.com/topic/811-flickering-in-old-games-on-nvidia-very-strange-problem/

    Regards, Veedub

    • gho

      Ok, I’ll do my best.
      Unfortunately MS changed a lot of things in these last years and, despite the declaration of Win10 as the last Window version, it has a dynamic patching feature (shims) that makes things changing (usually for the better…) almost every day, but this way you can never say you’re done wirh a game!
      One very positive thing is that now Win95/98 emulation is no longer made through a virtual machine, then it is now compatible with DxWnd and the two mechanisms (Windows compatibility assistant and DxWnd) can help each other to reach the goal.
      Wait for news (and if they don’t come, remind me every now and then….)
      bye

  • gho

    I compared the dxwnd logs of gpwxp2 and your gpwv103b, and the cause of the ‘Sample App Did Not Properly Clean Up Objects’ error message is the lack of Release upon the backbuffer surface, that is also linked with two references to the directdraw session and inhibit the resource freedom (see picture).
    The error message can be easily eliminated setting the DxWnd «return 0 refcount» instead of «fix ddraw refcount», but this is just a fake 0 number returned to the application while the resources still have references, and I suspect that this causes the block of the application right after that.
    I attach also the full log files, in case they could help to localize the code that needs a fix.

     

    Last edit: gho 2016-05-07

    Thumbnail

  • gho

    Bad news: in the attempt to trick the program and make a workaround, I made a sperimental version of DxWnd that counts (and logs) the DirectDraw4::Release() methods, so I found that the missing call is after the 19th cycle and I modified again DxWnd so that it doubles the Release call when the counter reaches 19.
    The result is that the error message no longer appears, the logs show that the game go further ahead, but it keeps stopping on the splash screen (or maybe it is not stopped, but the output operations are not visible?).
    In any case, it seems that the missing Release operation is not your only and main problem!
    In attach the crazy dll that makes the trick, just in case you want to see what changes (nothing at all).

  • Veedub

    Thank you for your efforts so far Gho — at least it gives me some leads to go on when I get to analysing the code. In v1.03b i have freed up a lot of bytes in the exe to write new asm, so potentially (if i’m clever enough) I can rewrite the start up sequence and see what I can eliminate or copy over from gpwxp.exe, and get something working in Windows 10. :) We dont have many clues from the developers as to what they actually changed between gpw.exe (v1.00) and gpwxp.exe to make it XP compatible but as far as I could tell it was recompiled with a newer version of Visual C++ (upgraded from v4 to v5) and probably had minor code changes, so that could be the subtle difference.


Log in to post a comment.

DxWnd

Window hooker to run fullscreen programs in window and much more…

Status: Beta

Brought to you by:
ghotik

  • Summary

  • Files

  • Reviews

  • Support

  • Home

  • Code

  • Discussion

Menu

Grand Prix World


Created:

2013-06-07

Updated:

2021-06-14

  • aqrit

    I was able to CreateProcess() __COMPAT_LAYER=256Color on Win7 32-bit

    • gho

      I tried and succeeded too, that is fantastic!
      The only big trouble is that activating compatibility mode seems to inhibit dxwnd hooking, making it perfectly useless…. But I kind of remember it was possible to hook a program with compatibility modes set. Either I don’t remember exactly, or something happened to my PC!

  • Veedub

    Just a heads up, GPW breaks with 2.02.43. Getting error «Sample app did not clean up objects» or so, which I know is a debug message in gpw.exe. From what I remember its part of the preliminary tests before launching the game. No major…

    Couldnt test with v2.02.42, as the dll is missing from the download package. But happily playing GPW with 2.02.41 for now. :)

    • gho

      You should check the «DirectX / Fix ddraw ref counter» flag.
      I wasn’t sure it was possible and safe to do this trick on all games, so I left it as a optional (defaulted) feature.
      Does this fix the problem, or was it checked already?

  • Veedub

    Hi Gho, sorry for the late reply. Yes, good news is that v2.02.43 works correctly, once the ‘Fix ddraw ref counter’ flag is checked. I also noticed that the game now shuts down correctly without error, and doesnt freeze. :)

    FYI I just tried the latest version 2.02.48 but GPW doesnt seem to like the changes. It flicks into full screen mode, and then back to windowed mode and the window stays black, which is quite a change to earlier verisons. Not a problem for me, as I’ll just use the v2.02.43 but just letting you know. Cheers

  • gho

    I think that newer releases of DxWnd should still let you play Grand Prix World finely: I noticed some problems with the earlier configurations, but that could depend on some garbage config flags that are not visible in non-debug mode: would you try to save a copy of your dxwnd.ini file, then run DxWnd, delete the config entry for this game and create a new one from scratch (or import it from the export folder): maybe that could fix the problem?

  • Veedub

    Hi Gho, thank you for your earlier work for GPW to run under DxWnd.

    Can I please request that the DXW export file for Grand Prix World is updated so that the «DirectX / Fix ddraw ref counter» flag is checked by default. This will help those who will inevitably strike this problem on future releases of DxWnd when giving GPW a go.

    I can confirm the current version 2.02.79 works a treat with GPW (once the flag is enabled), and I see you’ve made some fantastic additions over the last six months, especially obtaining elevated rights. Great stuff. Many thanks for your work.

    • gho

      Done. The change will be available (if I don’t mess with files again!) in the next release, the «DirectX / Fix ddraw ref counter» flag checked by default and the logging disabled (that could prevent some gamer to find his HD flooded with gigabytes of trace messages).
      For those who can’t wait, here is the new export in attach.

      Last edit: gho 2014-06-17

  • Jops

    Hi gho, thanks for all your work on this with Veedub, made some huge improvements to one of my all time favorite games. Unfortunately i’m not much of a programmer at all, but I wondered if you knew a way of getting this working on Windows 8.1 (the killer to all old games). Get a lot of different effors, the usual is «%%%Sample app did not properly cleanup objetcs»

    Tried compatability mode and installing to C//: root, but no success. Thanks.

    • gho

      I have to admit that not owning a Win8.1 licence I have no way to replicate this problem. I don’t know if anyone can help suggesting what to do….

      • ivdok

         

        Last edit: ivdok 2014-12-25

        • gho

          The problem is I’m not so sure I want this win8.1 rubbish even close… within a vm, maybe…
          ;)

          Last edit: gho 2014-12-25

  • Bisovic Béla

    Hello!

    I just noticed this site yesterday and I think this program very useful. The only problem is: it doesn’t work for me..What could be the problem? I do everything like you wrote here but GPW runs in full-screen mod no matter what.
    I downloaded the latest build and I run it as an administrator. I also try it with F1C 99-02 but pretty much the same.
    My operation system is win7 64bit. I use a 21:9 LG monitor with 3440*1440 desktop resolution.

  • Bisovic Béla

    Hmm, I unchecked the win 98/ME in the gpw.exe compatibility and it runs in windowed mode but the game freezes when the FIA logo comes.

    • gho

      The game is working for me on Win10 and latest release. I’d start replicating the same environment, so please, if you didn’t do that already, install latest release v2.03.49.fix3 and use the included import file for GPW, that you can find in the «export» folder.
      I’m pretty convinced that this won’t fix the problem that will be still there, but in this case you should activate the log flags as shown in the screenshot below, run the game until it freezes, kill it by the DxWnd «kill process» command (or with the task manager), seek for the dxwnd.log file that should be created in the game install folder, compress it and send it to me.

  • Bisovic Béla

    Now, works me too with the gpwxp.exe because no need to compatibility mode with it. With the 1.03b gpw.exe it needs. If I unchecked it works with it too but the game crashes at the FIA logo.
    I would like to run it with the 1.03 because this patch has a lot of good thing in it. By the way..is time stretch working for you? I set it to 16x but I don’t see any changes.

    Last edit: Bisovic Béla 2015-12-31

    • gho

      I think that to replicate exactly your environment I need to install the game and the patch exactly as you did, from the same files you used. If you prefer, you can PM me with instructions and links using the sourceforge messaging.

      update

      Environment and problem perfectly replicated. Now comes the hard part …. fixing it.

      Last edit: gho 2015-12-31

  • Bisovic Béla

    I read a comment on an other site. Here it it is:

    The problem: «The game will load in a window but will freeze at the FIA logo screen. When compatability mode is set for the exe it launches as it normally would in fullscreen. I tried the solution that was provided in the post but it did not work for me either.»

    And the solution: «On a good note I managed to get DxWnd to work. It would appear that DxWnd doesn’t like you using a path which contains a space.

    I had originally named the folder in my root C directory as «Grand Prix World». After changing it to «GPW» DxWnd recognised it.

    Therefore, I assume the reason why the installation in «Program Files» doesn’t work is not necessarily down to administrator privileges but rather the folder name contains a space.

    On a bad note, the game crashes following the conclusion of the race after the constructor points table has been displayed. I’ve tested the original exe, 1.01 and 1.03b and they all crash at this point.

    Do you have any ideas what the issue might be?»

    I tried it but i get the following error message «Try to enabling the reference rasterizer by executing EnableRefRast.reg»

    • gho

      I tried to eliminate spaces in the current path and also to move everything in C:GPW, but nothing changed: the game keeps freezing.
      I did some debugging, the main thread keeps locking on semaphores, but that could be normal, if it is waiting for the intro movie termination.

  • Bisovic Béla

    Hmm..its really sad because th timing stretch speed up the game perfectly with the gpwxp.exe :)
    So it would be very cool if i can play with the 103b too.

    • gho

      Never say never ….. but the patch classified as a «beta» let me think that it could be a different problem. In any case, I’ll keep working on it.

  • Bisovic Béla

    On my laptop it works but when I start a race weekend than the screen crashes like when the vga is wrong. It also happened 2 days ago on my pc. I change the values in the ‘window initial position and size’ section but now this didn’t help and I don’t know why.
    On the laptop the race screen also crashes with the gpwxp.exe too. In the menu everything is fine until I start a race weekend.

    Last edit: Bisovic Béla 2016-01-03

    • Marc

      I haven’t tested a race yet, but I think I’ve got the ‘hook’ from DxWnd to the gpw exe working.

      I think the one thing I did that’s different from what I’ve seen hear is that I went into the compatability settings in windows explorer and tried Win95 on the exe itself, instead of the Win98 settings. I think it was that change that got it past the lock up on the gold FIA screen and into the program.

      So, I’m in the program in a windowed mode. Its late, so I haven’t tested a race and the main thing I’m trying to solve which is an awful flicker in the game which also seems to bring the processing of a race to a crawl. I’ll have to try to beat on it some more and see how good this realy is.

      The one odd thing right now is that on a two monitor screen, the first window with the DxWnd logo is on my main monitor (with windows task bar), while the window for the game then opens on my 2nd monitor.

      This is all on Windows7. My DxWnd export is attached. Although, there might be some odd settings in there as I did a bit of checking things I don’t understand during a phase when I was trying to get it working. :)

      Last edit: Marc 2016-03-22

      • Marc

        Hi, I feel like I’m close, but not there yet.

        The race sequence runs and doesn’t crash. But the colors are all wrong. Kinda like when something’s wrong with the palette in an old game, except there’s also an effect of diagonal pattern running through this. I can see some of the controls that seem to be ‘on top’ of the graphics, so I can easily see and press the button that lets me go to the options screen. That displays well, just like the main program, so I can exit the game and try again.

        So, I think what I need is some help with some of the many options to try to fix two problems.
        1) The bit where the window appears on my main monitor, but the graphics that should be inside instead paint in the same place on the secondary monitor.

        2) Getting the colors and display correct in the race sequence displays.

        If you have any suggestions on which of many checkboxes might address those sorts of issues, I’d appreciate any help someone wants to toss my way. Otherwise, I can always just try my random check-box ticking to see if I can stumble upon any answers.

        The good news is that the bad display with the messed up colors doesn’t seem to ‘flicker’ any more. Hard to tell, as before it would sometimes go several seconds before beginning this action, so maybe I’m just not waiting long enough before exiting. But, like I said, I feel like I’m close.

        Thanks for the excellent tool and the good info I’ve found above. :)

        • gho

          Things you may try:

          1) send me a full printscreen of your double-monitor desktop when the problem appears (just hit the print-screen key without the Alt key)
          2) Set the Video / «Hide multi monitor config.» flag that will let the program you have a single monitor (though I doubt it will work….)
          3) if you see diagonal stripes, that could be cured by two flags that (for lack of space) I put in the Direct3D section: «Lock / Unlock pitch fix» and «Width no power of 2 fix».

          The palette problems could (I don’t know why, but it worked with «Men in Black»!) be fixed chosing the Libs «Share ddraw and GDI DC» option.


Log in to post a comment.

DxWnd

Window hooker to run fullscreen programs in window and much more…

Status: Beta

Brought to you by:
ghotik

  • Summary

  • Files

  • Reviews

  • Support

  • Home

  • Code

  • Discussion

Menu

Grand Prix World


Created:

2013-06-07

Updated:

2021-06-14

  • Marc

    Thanks for the ideas.
    Here’s a picture of the desktop, although if you were asking about the problem of painting in on the wrong screen, I’d fixed that issue (see post below) and this now shows the painting inside the proper window frame. Before, the part that should have been within the frame was appearing on the other monitor with the same (or close) 50,50 offset from the top-left of that display. So, the frame was on the main window (right side of this image) while the painting was occuring on the left side.

    The image does show what the race mode looks like now.

    When I tried the two flags (Lock/unlock pitch fix and Width no power of 2) together, the overall graphics of the game were scrambled on stop and I had to kill the program. The Lock/unlock pitch fix flag alone does the same, while the Width no Power of 2 flag alone runs the program but has the same look to the race screen as in the screen shot. The Share ddraw and GDI DC option alone had the same look also.

  • Marc

    OK, got a step closer.

    First, I went back to the file for GPW that comes in the ‘exports’ folder. Left the windows explorer compat settings alone.

    Then, I found a checkbox that says «Don’t Fix Pixel format» under the DirectX tab and checking that makes the ‘paint’ occur inside the window on my main monitor. So, one issue down. The race is still unreadable due to color or other issues, but now I seem to be down to one issue. :)

  • Anonymous

    Hi Marc, this method is worth a try. Go to Direct3D tab > uncheck «Fix ddraw refcount» and check «Return 0 refcount». Does that make the problem less serious?

    If this method not work, please revert to previous setting.

    • Marc

      Pretty much the same. Here’s a pic, but it looks a lot like the one I just cleared ouf of Paint.

      Thumbnail

  • gho

    I saw the picture, and it is strange indeed. This sort of things usualy happens when the program doesn’t manage the graphic in the proper way (that is using the system calls) but takes some shortcut for supposed optimization and generates a full mess.
    Usually the problem disappear if the program works in the exact resolution he supposes to be. Could you try to set the window heigth and width values to 0, 0 in the main DxWnd conf panel and see if the problem disappear?

    • Marc

      OK, here goes then. I’ve got the check box back to «fix ddraw refcount’, and now the H and W set to 0.

      With game programmers, especially from that era, it wouldn’t surprise me at all if they were doing some shortcuts. Strange, a game like this they shouldn’t have had to, but the game is littered with these useless 3d views of race cars on a race track so they may have done something to get more speed in there.

      Had to wait for it, Program was slower to appear. Then had trouble getting the mouse to work. But in the end, it got to the race mode and no difference.

      At this point, I think I’m still close to the shipped settings for GPW, with the changes put in to test and then removed once they don’t work. But, here’s a export of my latest version.

      BTW, I think 800 x 600 was the correct size (values in H and W before I tried 0 and 0). I think I saw that somewhere in display settings while messing around with this in fullscreen (no dxWnd) mode.

      Thanks for the help and for giving it a try. :)

      • gho

        What happens if you temporarily turn off your secondary monitor and configure the desktop accordingly? I’s like to be sure the problem depends on the two monitors, and this test is pretty easy to do.

  • Gianmarco Marzo

    I fear that I need help.
    I tried running GPW through DXWnd following the steps listed in this guide: http://www.gprm.co.uk/forums/index.php?topic=5835.0

    But I alternatively get these two error messages:

    1 «sample app did not clean up objects»
    2 (much more frequent) «%%%sdevices. Try enabling reference rasterizer by running refrast.reg» (a file that does not appear to exist on my computer).
    What’s going on? T_T

  • gho

    Hi Gianmarco,
    I’ m replying from mobile phone but it’ s not easy.
    I’ll be back from holyday twesday, I will make tests then.
    Be patient and happy Easter.

  • Gianmarco Marzo

  • gho

    Here I am. back to work.
    The problem may depend on the version of the game. What I’m actually supporting is a variation of the windows XP port of the game, «gpwxp2.exe», that I can’t even remember how exactly I got it.
    In any case, I would make a clean start putting both you and me in identical conditions: so, please
    1. download the latest DxWnd release v2.03.58,
    2. import the included file «Grand Prix World.dxw» from the DxWnd export folder
    3. unzip the attached version of the game in the game folder.
    4. adjust the dxwnd path field in the configuration so that it points to the gpwxp2.exe file.
    At this point, If it doesn’t work, at least we will share equal conditions.

  • Gianmarco Marzo

    Hello Gho,
    thank you. I will try this out in the afternoon as soon as I am back home and tell you what happens.
    Hope you had pleasant holidays.

  • Gianmarco Marzo

    Okay Gho,
    I tried. I think we’ve made progress. It now says «ensure that game CD is inserted». I suppose I need a no-CD patch of some kind.

    • gho

      Uhm…. no, I think that the problem is that you didn’t install the full gpwxp patch, that likely copies more resourced on hard disk and makes the CD useless. I provided just the exe, but this is not enough.
      Have a look at here: http://www.simracingworld.com/files/download/1086-grand-prix-world-windows-xp-patch/ and follow the instructions. In any case, keep the gpwxp2.exe that I sent you because it may work better with DxWnd (Oh, my! I can’t remember why I patched it!)

  • Gianmarco Marzo

    Hello Gho,
    I downloaded the patch you linked, and kept your exe, but I still get the no cd issue.

    • gho

      What OS are you trying to run it on? I heard that some copy protection schemas were left unsupported by MS recently, and maybe with the protection, also the crack was gone …
      In any case I had it working on WinXP, Win7 and Win10. I left untested only Win8 and 8.1.
      More likely, there must be some error in the installation, but from here I can hardly tell….

      Last edit: gho 2016-04-02

  • Gianmarco Marzo

    I am running it under windows 8.1.
    I tried with a pirated version of the game. It’s hard to find a legitimate copy and I would be hesitant to buy it when it may very well not run at all. :/

    • gho

      I never had the (mis)fortune to verify this, but the general opinion on Win8.1 is not very good, since it gained on the field the nickname of «Game killer»!
      You should have a proposal from MS for a free upgrade to Win10, and even if you don’t, there should be a way to di that for free. My personal suggestion is to migrate to Win10: I also was a bit reluctant, but then I migrated directly from Win7 to Win10 in a single step and it was absolutely ok: you loose nothing (as far as I can tell) and you gain some disk space (strange, but true), a more efficient OS and a better back-compatibility with everything, including an integrated support to emulate 8 or 16 bit color depth in a window (they must have copied something from DxWnd, I dare say…).
      In any case, I’m afraid I can hardly support you on 8.1, since I don’t have it. The only final attempt could be to try the last DxWnd beta that I updloaded a few hours ago: that manages much better some latest Window versions.

  • Gianmarco Marzo

    Thank you gho, you have been very kind and I sincerely appreciate that.
    The upgrade to Windows 10 sounds nice. I will consider it, first I want to verify what the web says about the other games I play often running under 10, but since they’re mostly recent I don’t think it’s going to be a problem.
    I will come back to you as soon as I have upgraded to 10 and let’s see if that fixes things.

    • gho

      Release v2.03.60 fixed many problems about ddraw method hooking, that has become more and more selective from WinXP up to Win10. If you like, you may also try this last version, there’s a slight possibility of improvement.

  • Veedub

    Hey Gho, the OP back again :)

    For future tests, can you please test Grand Prix World with DxWnd and gpw103b.exe? Basically, while gpwxp.exe was repackaged by the developer to work with Windows XP, it isnt the latest official version of the game. The latest official version is gpwv101b (packaged for Win98), and I managed to patch out the WinXP bugs and get it working with Windows XP eventually (creating the unofficial gpwv103b.exe). So as a community, we want to use gpw103b going forward where possible.

    You will need to install gpwv101b first, and then apply gpwv103b (which is also a no-cd exe).
    gpwv101b: http://www.edwardgrabowski.com/downloads/gpwv1.zip
    gpwv103b: http://s000.tinyupload.com/index.php?file_id=66902834389965582469

    Of course for GPW to run on any system, you should set compatibility mode on the gpwxxxx.exe file to Windows 98 to get past the game freezing at the gold FIA logo.

    I’m hoping you can help us with the following problem a user has raised to my attention:

    • Unfortunately the 103b patch doesn’t run on Windows 10 but apparently gpwxp2.exe does
    • The same error messages that came up in that Sourceforge thread appear —
    • ‘Sample App Did Not Properly Clean Up Objects’ if you use XP Compatibility mode and
    • ‘Try enabling the reference rasterizer by executing EnableRefRast.reg’ if you use Windows98 compatibility mode.

    I suspect these errors relate to when the game initialises and tests the hardware/software graphics capabilities. As it is Windows 10, I have very little knowledge on this issue but I’m hoping you may understand what is causing these checks to fail or how to bypass them. Apparently the gpwxp2.exe that you created at the start of the thread does seem to work with Windows 10, so it may just be possible to get gpw103b.exe working as well. I did a binary diff on gpwxp.exe, and your exes gpwxp2.exe and gpwxp3.exe to note your changes and will see if I can carry those changes across to gpwv103b.exe (I’ll have to fire up idapro, and cross reference the code) but I suspect there may be more issues to solve. The two versions (gpw101b.exe and gpwxp.exe) have quite different disassembly layouts but the same start up logic.

    Thank you for your efforts so far, any help appreciated. I’ll let you know if I make any discoveries, once I get my own Win10 box up and running, hopefully one day soon.

    Also, not DxWnd related but it is graphics related, can anyone/graphics experts explain this issue with flickering graphics? From the ~3:30 mark in the video, the UI starts to flicker. This is when playing the game normally at full screen on any system/OS. Some system configurations cause the flicker, others work perfectly fine. Our suspicions are that its graphics hardware/driver related (possibly nvidia only). I wonder if it is GDI vs DirectX interference or something or clockspeed, as I notice the system that the game flickers on has unhelpfully super responsive button clicks?

    Youtube video: https://www.youtube.com/watch?v=0glTWBjZHXk&t=3m30s
    Google suggestion: http://community.pcgamingwiki.com/topic/811-flickering-in-old-games-on-nvidia-very-strange-problem/

    Regards, Veedub

    • gho

      Ok, I’ll do my best.
      Unfortunately MS changed a lot of things in these last years and, despite the declaration of Win10 as the last Window version, it has a dynamic patching feature (shims) that makes things changing (usually for the better…) almost every day, but this way you can never say you’re done wirh a game!
      One very positive thing is that now Win95/98 emulation is no longer made through a virtual machine, then it is now compatible with DxWnd and the two mechanisms (Windows compatibility assistant and DxWnd) can help each other to reach the goal.
      Wait for news (and if they don’t come, remind me every now and then….)
      bye

  • gho

    I compared the dxwnd logs of gpwxp2 and your gpwv103b, and the cause of the ‘Sample App Did Not Properly Clean Up Objects’ error message is the lack of Release upon the backbuffer surface, that is also linked with two references to the directdraw session and inhibit the resource freedom (see picture).
    The error message can be easily eliminated setting the DxWnd «return 0 refcount» instead of «fix ddraw refcount», but this is just a fake 0 number returned to the application while the resources still have references, and I suspect that this causes the block of the application right after that.
    I attach also the full log files, in case they could help to localize the code that needs a fix.

    Last edit: gho 2016-05-07

    Thumbnail

  • gho

    Bad news: in the attempt to trick the program and make a workaround, I made a sperimental version of DxWnd that counts (and logs) the DirectDraw4::Release() methods, so I found that the missing call is after the 19th cycle and I modified again DxWnd so that it doubles the Release call when the counter reaches 19.
    The result is that the error message no longer appears, the logs show that the game go further ahead, but it keeps stopping on the splash screen (or maybe it is not stopped, but the output operations are not visible?).
    In any case, it seems that the missing Release operation is not your only and main problem!
    In attach the crazy dll that makes the trick, just in case you want to see what changes (nothing at all).

  • Veedub

    Thank you for your efforts so far Gho — at least it gives me some leads to go on when I get to analysing the code. In v1.03b i have freed up a lot of bytes in the exe to write new asm, so potentially (if i’m clever enough) I can rewrite the start up sequence and see what I can eliminate or copy over from gpwxp.exe, and get something working in Windows 10. :) We dont have many clues from the developers as to what they actually changed between gpw.exe (v1.00) and gpwxp.exe to make it XP compatible but as far as I could tell it was recompiled with a newer version of Visual C++ (upgraded from v4 to v5) and probably had minor code changes, so that could be the subtle difference.


Log in to post a comment.

Memory Leaks

When it comes to unit testing in AngularJS there are many things that, developers like us can and will do wrong. The most crucial one is to create memory leaks in our unit tests, which mostly result either in a crash of the unit test runner (browser crash) or in creating a coherence/dependency between different tests that are meant to be separated. This article shows the basic mistakes that are done out in the wild and illustrates the rather easy fix.

Beware as this article only covers the analysis of the Jasmine testing framework. I didn’t invest any time in checking what happens in other frameworks like Mocha.

tl;dr;

  • Do not declare any var outside of a ‘it’-block unless you null it manually after the test
  • Declare shared variables on this, those variables are shared between: beforeEach,
    afterEach and it and are properly cleaned up by Jasmine
  • if you use $compile, call remove() on the created element when you are done testing it (e.g. in an afterEach)

How we noticed there was a memory leak

When you’re starting a fresh project you are unlikely to run into memory leaks. I found out about the problems when I joined another project with more than 3.500 unit tests. I write Angular applications for about 2-3 years now, but when we discovered what we were doing wrong in our unit tests it got me thinking…

Heres how we noticed there is a problem. It has been fairly simple: the browser, that executed the unit tests crashed. We were using Firefox as a runner, since PhantomJS quits its job about a year ago with ~1.000 unit tests and Chrome did so a while later. This time Firefox started to crash as well, we seemed to hit the max. capabilities of Firefox as well. There was no other choice then to find out what exactly broke the unit tests. We figured out that it must had something with memory leaks to do, because the browser ate to much memory until it collapsed. It also showed this strange behaviour that it would make huge pauses between some tests and the pauses then became longer, the more tests were executed.

After using Google for while we found a sample projects that illustrates two ways angular unit tests can leak memory. So I made a fork of it and tried to find a suitable solution that fits our needs

https://github.com/kaihenzler/ng-unit-testing-leak

Setting up a sample app

The sample app essentially contains only one directive and one service. What the directive does consists of just requesting a very big Object from the service and using ng-repeat to loop over this huge object.

To explain the issue we checked out the GitHub-Repo mentioned above and run a couple of commands. First of all we started with npm install, followed by bower install. Then, we started the unit tests by typing ./node_modules/karma/bin/karma start karma.conf.js in the console.
After about a minute we have seen that we executed 3.000 unit tests.

running-unit-test

Successful unit test run

To get the tests to fail we need to edit 2 files:

  • We uncomment the lines 47-49 in test/directives/heavyLoad-directive.spec.js and
  • comment the tests in line 79-81 of heavyLoad-directive.using-this.spec.js.

(what we do, is just disabling “valid” unit test and enabling the faulty one..  we’ll explain more details later).

A second run of ./node_modules/karma/bin/karma start karma.conf.js now gives us the following result:

crashing-unit-test

crashing unit test

Why does the test-run fail?

To find out why the test is killing our browser we launched the test suite in Google Chrome. At some point (test was running since ~30 sec.) we set a break point (to cause the test suite routine to pause) and then we opened the profile-tab of Chrome’s DevTools to take a Heap Snapshot.

heap snapshot of the failing unit test suite

When we took a quick look at this Heap Snapshot I was really surprised on how big it was. I expected not more than (maybe) ~25 MB of memory usage. But as Note 1 marks we reached over 800 MB in about 30 sec.

Note 2 showed us where this huge pile of memory usage came from. We can see from that picture that the 92% of the memory has been used by some arrays…you might be wondering: “where are we storing such a huge amount of arrays in our little demo application?”

Note 3 shows us that the stored arrays look just like the ones returned from our service, that generates huge data structures.

You have to trust me, that there is not only one Object (like the one marked in red) but there are literally thousands of them.
This can mean only one thing: Our unit tests seem not to cleanup properly and somehow keep references of previous test runs in memory.

let’s have a look at the test code which causes this strange behaviour. Previously we executed this ‘describe’-block 1.000 times, in order to make the memory leak to appear.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

describe(‘heavyLoad effective directive’, function () {

    var heavyLoad, $compile, element, $rootScope, $scope, compileDirective;

    beforeEach(module(‘app’));

    beforeEach(inject(function (_$rootScope_, _$compile_, _heavyLoad_) {

        $rootScope = _$rootScope_;

        $compile = _$compile_;

        heavyLoad = _heavyLoad_;

        $scope = $rootScope.$new();

    }));

    compileDirective = function (template) {

        element = $compile(template)($scope);

    };

    it(‘should compile correctly’, function () {

        spyOn(heavyLoad, ‘getHeavyList’).and.callThrough();

        compileDirective(‘<div heavy-load></div>’);

        expect(heavyLoad.getHeavyString).toHaveBeenCalled();

    });

});

There are a few things to notice here, in that, this layout of the test follows the official angular unit testing guideline where we:

  • declare shared variables inside the describe block
  • instantiate the app in a beforeEach
  • inject Components in a beforeEach
  • use an helper function to e.g. compile a directive
  • have one or multiple ‘it’-blocks that test various things and use those declared vars and functions

Unfortunately something here seems to be wrong. As we saw in the previous chapter, where we took a look at the Chrome Profiler, none of the shared variables seem to be cleared after the execution of a ‘it’-block. That’s because Jasmine builds up a tree from all registered test suites and each suite contains references to the beforeEach- and afterEach-functions. Those references, in turn, contain other references to the described function closure which holds other references to the shared variables…and the large objects that are referenced by that variables won’t be GC-ed (Garbage Collected) until Jasmine stops the execution.

This may sound confusing at a first glance: let me put it in simple words. If a variable, that is defined inside a ‘describe’-block has a value assigned (which is not null or undefined) the Garbage Collector of your Browser is not able to cleanup the related memory, because Jasmine internally holds a reference to that block.

Fixing the Unit Tests

As I mentioned before, we have to set all those variables declared inside each describe to null. Let’s do it:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

    describe(‘heavyLoad effective directive’, function () {

        var heavyLoad, $compile, element, $rootScope, $scope, compileDirective;

        beforeEach(module(‘app’));

        beforeEach(inject(function (_$rootScope_, _$compile_, _heavyLoad_) {

            $rootScope = _$rootScope_;

            $compile = _$compile_;

            heavyLoad = _heavyLoad_;

            $scope = $rootScope.$new();

        }));

        afterEach(function () {

            heavyLoad = null;

            $compile = null;

            $rootScope = null;

            $scope = null;

            compileDirective = null;

            element = null;

        });

        compileDirective = function (template) {

            element = $compile(template)($scope);

        };

        it(‘should compile correctly’, function () {

            spyOn(heavyLoad, ‘getHeavyList’).and.callThrough();

            compileDirective(‘<div heavy-load></div>’);

            expect(heavyLoad.getHeavyList).toHaveBeenCalled();

        });

    });

If we would run our unit-tests again, they shouldn’t crash again, right? Unfortunately they still do.
After an harder debugging session it became clearer that the usage of $compile seemed to be the main cause of the memory leak. In fact, after attaching a debugger we saw that $compile generates a DocumentFragment (we can think of it as a light-weight Document). As we didn’t attach the DocumentFragment to the actual DOM, we cannot see our compiled template in the Elements-Inspector when we debug our tests, but what we can do is to search in the Heap Snapshot for occurrences of DocumentFragment.

And as we can see, there are a lot of DocumentFragments laying around. You can guess what is about to do next: we take care of proper cleanup of the $compile in our unit test.

A deeper look at the Chrome Profile from above showed, that these elements were somehow linked to a jQuery cache. I figured that I might dive into angular’s source code. Unsurprisingly it helped a lot. In some of angular’s directive tests they cleanup the DOM in an afterEach-block, where they call a helper function ‘dealoc’ from their testHelpers and it indeed does some cleanup of cache-related jQuery things.

I didn’t spent a lot of time but went to the angular-bootstrap repository, which is a great source for good angular-code. In the first directive spec I looked at (the accordion), I noticed that they remove the element from the DOM in an afterEach block.

So that’s what we’ll do as well: we add one line and remove the element.

afterEach(function () {

    heavyLoad = null;

    $compile = null;

    $rootScope = null;

    $scope = null;

    compileDirective = null;

    element.remove();

    element = null;

});

and finally, our unit tests run gracefully without any hiccups. But is that what we want to do? Cleanup every little bit of what we defined? Read further and I’ll show another approach to Jasmine unit tests!

How to make your tests look even cleaner

Let me introduce you a well known paradigm in almost every programming language: Jasmine’s this. Jasmine provides a this which can be used to share variables between beforeEach, afterEach and it. Isn’t it exactly the same that we wanted to accomplish with our test setup? (as we defined a var inside a describe block, in order to let the beforeEach and it-blocks accessing those vars). In my opinion it is! Let me show you how this test could look like, if it’s written with this-syntax.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

describe(‘heavyLoad effective directive’, function () {

    //declare the module you want to instantiate

    beforeEach(module(‘app’));

    //you don’t have to use underscore syntax like ‘_MyService_’ because we assign the injected components onto ‘this’

    beforeEach(inject(function ($rootScope, $compile, heavyLoad) {

        //assign all the injectables to ‘this’ for all the other ‘beforeEach’, ‘afterEach’ and ‘it’-blocks

        //share the same ‘this’

        this.$rootScope = $rootScope;

        this.$compile = $compile;

        this.heavyLoad = heavyLoad;

        this.$scope = $rootScope.$new();

        //create spy’s and execute the original function

        spyOn(this.heavyLoad, ‘getHeavyList’).and.callThrough();

    }));

    //declare your test helpers in a beforeEach-block so they have access to ‘this’,

    //give the function a name like testHelpers because it’s easier for your colleagues to find the test-setup code

    //it is best you don’t use ‘var’ anywhere but in ‘it’-blocks so you don’t have to take care of proper cleanup

    beforeEach(function testHelpers() {

        this.compileDirective = function (template) {

            this.element = this.$compile(template)(this.$scope);

            this.directiveScope = this.element.isolateScope();

        };

    });

    // NOTE: still needed cleanup

    afterEach(function () {

        //prevents DOM elements leak

        this.element.remove();

    });

    it(‘should compile correctly’, function () {

        //’var’ is allowed in an ‘it’-block and doesn’t have to be null-ed

        var givenTemplate = ‘<div heavy-load></div>’;

        //prepare the directive (this function is defined on ‘this’ in beforeEach)

        this.compileDirective(givenTemplate);

        //go through your assertions. here we have access to the ‘this’

        expect(this.directiveScope.title).toBeDefined();

        expect(this.directiveScope.items).toBeDefined();

        expect(this.heavyLoad.getHeavyList).toHaveBeenCalled();

    });

});

advantages of this-syntax:

  • Jasmine takes care of properly cleaning up everything that is defined on this
  • You can directly write-to and read-from this, no need to setup a var on the right function scope for all those it-blocks, beforeEach and afterEach blocks to be accessible.
  • Someone will always forget to write cleanup code, because it is very hard to locate where a manual cleanup might be necessary.
  • Why reinvent the wheel, when Jasmine gives us exactly what we need.

disadvantages of this-syntax:

  • You have to go through every single file and possibly change every 2nd line (although search/replace is your friend).
  • Most unit tests would only need one additional afterEach block where you could null all vars.
  • this has a bad reputation in the JavaScript community because it appears to do weird things sometimes.

It’s not up to me to decide what you shall end up doing.
IMHO the this-syntax seemed to make the things easier, because I tend to forget to write the proper cleanup code in unit tests.

A huge shoutout goes to Sashe Klechkovski, who came up with the demo-app and brought me to the suggestion of this-syntax.

This error appears in console on scene load:

Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)

I know it’s because I Instantiate an object in an OnDestroy method and I know how to fix this problem on application quit. But I don’t know how to fix this on scene change with SceneManager.LoadScene()

Is there any method for this need, something like OnSceneUnload?

asked Apr 12, 2016 at 15:11

rap-2-h's user avatar

1

I was having a similar issue instantiating objects in OnDisable.

What worked for me was to check if the scene was still loaded in OnDisable. This returned false both when quitting the app/editor and when unloading the scene.

void OnDisable()
{
        if(!this.gameObject.scene.isLoaded) return;
       // Instantiate objects here
}

Dharman's user avatar

Dharman

29.2k21 gold badges79 silver badges131 bronze badges

answered Jun 25, 2021 at 7:18

NTok's user avatar

NTokNTok

711 silver badge2 bronze badges

2

You can use OnLevelWasLoaded(int level) like:

    void OnLevelWasLoaded(int level)
    {
        if (Application.loadedLevelName == "MyNextScene") 
        {
            // Clean Up leaked objects
        }
    }

It is called when scene changes.

UPDATE:

Above suggestion was to create script that isnt cleaned up when new scene is loaded, so basicly you need to use something like this in this script:

void Awake() 
{
    DontDestroyOnLoad(this.gameObject);
}

Then store this not cleaned up objects in some collection of this script, and let it clean it up for you when scene changes.

answered Apr 12, 2016 at 15:44

Jerry Switalski's user avatar

Jerry SwitalskiJerry Switalski

2,6101 gold badge15 silver badges34 bronze badges

3

It is common issue for who develops applications using Excel. As regular developing process, you create Excel objects for your Excel tasks. Then you remove these objects when you’re done with them.

The problem is that they don’t go away even you remove them! They stay at background. You see them at Task Manager:

After a while, you will see bunch of EXCEL.EXE processes running at background. So, is that the all we can do? Of course, it isn’t. Here is the solution:

Solution for cleaning up Excel interop objects

Actually, there several ways to clean them up. The thing is that none of them might not work or first one you have tried may work. Therefore, you should try all the ways below without giving up.

Your class for Excel tasks

It may looks like this:
Excel._Application app = new Excel.Application();
Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
Excel._Worksheet worksheet = null;
app.Visible = true;

worksheet.Cells[1, 1] = "test string";

workbook.SaveAs("C:testfile.xlsx");

object misValue = System.Reflection.Missing.Value;
workbook.Close(true, misValue, misValue);
app.Quit();

releaseObject(worksheet);
releaseObject(workbook);
releaseObject(app);

Your class for releasing objects

You may be using a class to release objects:

private void releaseObject(object obj)
{
    try
    {
        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj);
        obj = null;
    }
    catch (Exception ex)
    {
        obj = null;
        MessageBox.Show("Unable to release the Object " + ex.ToString());
    }
    finally
    {
        GC.Collect();
    }
}

Option 1: Give more time to the application

Change finally block in releaseObject class with this:

GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();

Garbage Collecter will wait for pending operations and try twice.

Option 2: Do not open Excel file in the same line

If you are opening an existing Excel file, use the code like this:

Worksheets sheets = excelApp.Worksheets; // &lt;-- the important part
Worksheet sheet = sheets.Open(...);

Instead of this:

Worksheet sheet = excelApp.Worksheets.Open(...);

Using two dots with COM objects is not recomended.

Option 3: Use Application.Quit as well

Like this:

app.Application.Quit();
app.Quit();

Option 4: Set objects to null, if you don’t need them

It may be helpful for the Garbage Collector

worksheet = null;
workbook = null;
app = null;

I know, you’re already setting them to null in releaseObject class. This is for double check.

Option 5: Make sure that you release all objects related to Excel

If you don’t release all objects, none of the options above can help you. Make sure you release all objects including range one!

Excel.Range rng = (Excel.Range)worksheet.Cells[1, 1];
worksheet.Paste(rng, false);
releaseObject(rng);

In this case, we are using Excel.range and releasing it.

Summary

This problem has been annoying developer for a few years. You can figure it out by using the information above.

If you still face this problem, try killing EXCEL.EXE process. I don’t recommend it because it may end up with killing Excel files which isn’t related to your application

September 25, 2013 — 9:53pm

#1

Offline

Last seen: 1 year 1 month ago

Joined: 2007-05-26 16:30

did not close properly last time it was run and will now clean up. Please then start xxx manually

Yes, I found the now-closed and long-running thread about this error message. My issue is slightly different, or perhaps here is new information.

My ongoing problem is with System Explorer. I completely deleted the entire System Explorer folder and replaced it with a fresh install. I’m still getting the error!

I had thought the program startup status would have been set or flagged somewhere in the app data or ini… BUT this seems to suggest that the error is held in the registry instead (which makes me wonder about portability, but that’s not at issue here).

Can anyone tell me how to find this status in the registry and reset it so System Explorer will run?

— Also I have no idea what is meant by «start [the program] manually.» Makes no difference if I go in through, say, PAM or PStart to run the program from a shortcut, or go into the PortableApps folder and open the program’s exe directly. Why would «manually» make any difference?

Unity Discussions

Loading

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Pick a username
Email Address
Password

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

I am relatively new to WPF, and some things with it are quite foreign to me. For one, unlike Windows Forms, the WPF control hierarchy does not support IDisposable. In Windows Forms, if a user control used any managed resources, it was very easy to clean up the resources by overriding the Dispose method that every control implemented.

In WPF, the story is not that simple. I have searched for this for several hours, and encountered two basic themes:

The first theme is Microsoft clearly stating that WPF does not implement IDisposable because the WPF controls have no unmanaged resources. While that may be true, they seem to have completely missed the fact that user extensions to their WPF class hierarchy may indeed use managed resources (directly or indirectly through a model). By not implementing IDisposable, Microsoft has effectively removed the only guaranteed mechanism by which unmanaged resources used by a custom WPF control or window can be cleaned up.

Second, I found a few references to Dispatcher.ShutdownStarted. I have tried to use the ShutdownStarted event, but it does not seem to fire for every control. I have a bunch of WPF UserControl’s that I have implemented a handler for ShutdownStarted, and it never gets called. I am not sure if it only works for Windows, or perhaps the WPF App class. However it is not properly firing, and I am leaking open PerformanceCounter objects every time the app closes.

Is there a better alternative to cleaning up unmanaged resources than the Dispatcher.ShutdownStarted event? Is there some trick to implementing IDisposable such that Dispose will be called? I would much prefer to avoid using a finalizer if at all possible.

  • Samsung 3175 ошибка ленты переноса
  • Samp ошибка the server didn t respond retrying
  • Samsung 2870fd ошибка u1 2330
  • Samp unable to execute ошибка
  • Samsung 2165 ошибка термофиксатора