Getting External Exception C0000006 in D2006 app - how can I force delphi to load the whole executable?
Asked Answered
H

3

2

I get this occasionally when exiting my app - my app is running the EXE over a network. I understand it's a page fault when part of the EXE is loaded on demand.

I have also observed it in the OnDrawCell method of a TDrawGrid, so I'm mystified how that might have caused a page load. Also, the exception kept happening.

So my questions:

Can Error C0000006 result from other causes? I have made fairly major changes to the way the app manages memory, though nothing out of the ordinary, and I'm confident the code is behaving.

How can you make the app load all of itself into memory on startup (in Delphi 2006 - I understand there are directives for later versions of Delphi).

TIA

Hendren answered 1/8, 2011 at 22:49 Comment(3)
possible duplicate of External exception C0000006Vinegarroon
@David. Yes it is, but that question left the impression that you couldn't do this in D2006.Hendren
I had the same problem. I had to test my executable on the "Windows XP Mode" from Windows 7 Virtual PC. I did that because my computers's client have XP-32 and I have Seven-64. Now I know that it is because I executed it from the Virtual Sync Disk that XP Mode uses. I have to copy the folder to the XP virtual disk and execute it.Hernadez
D
5

The directive $SetPEFlags seems to be part of Delphi 2006, at least Hallvard talks about it in this article in the context of D2006. Have a look here on how to use it.

Darlington answered 2/8, 2011 at 9:29 Comment(3)
@David. Great article. I added {$SetPEFlags IMAGE_FILE_RELOCS_STRIPPED + IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP} to the project file and shaved 370k off the 8MB executable.Hendren
@ross do you know the implications of using IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP?Vinegarroon
I actually asked that very question here on stack overflow yesterdayVinegarroon
V
2

We experience this too. The system puts some of the executable pages out to swap and then fails to page it back some time later. It appears to be related to network connections being restored after sleep.

The only viable solution that we have found is to locate executables on the local machine.

Vinegarroon answered 2/8, 2011 at 5:45 Comment(1)
Thanks @David. That would figure as the app allocates a reasonable chunk after startup. I've seen mention of modifying PE header flags but that sounds pretty scary.Hendren
B
1

This exception C0000006 also often occurs if your software is run from a network drive. To prevent that problem you can combine the flag

{$SetPEFlags IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP}

with the following flag:

IMAGE_FILE_NET_RUN_FROM_SWAP = $0800;

{$SetPEFlags $0C00}
Beamer answered 28/1, 2016 at 9:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.