三层次的问题:客户端有13个数据模块,服务器端也有13个程序与之对应,出现内存错误!(200分)

T

tomol

Unregistered / Unconfirmed
GUEST, unregistred user!
因为好几个人做该程序,又处于整合期,所以客户端数据模块没有合并,13个数据模块也
就有13个连接(用的是socket),13个数据模块都是程序自动创建的,除主窗体外的其他窗体
都是手动创建的,服务器端也有13个应用程序服务器与之对应.每个人单独的模块都没有
错误,所有手动创建的窗体都用了标准代码关闭(在Close事件里写Action:=caFree;在
Destory事件里写formXXX:=nil;),但是把大家的程序放在一起,在2000下关闭程序时
出现如下错误:
"0x004ce925"指令引用的"0x0234d708"内存.该内存不能"read"
在98下关闭程序时直接出现蓝屏错误.
各位高人:请帮帮忙,急着交程序呀,熬了几个通宵了.
 
这是我见过最烂的程序
这样的程序有存在的必要吗
一个客户端的连接可以少于一个,你不可想象吧
就是说 30个客户端 给服务器连接可以只有 15个
你的呢 有 300多个
太烂了
 
听不明白,俺不要分,只想学习一下
 
应该就是连接太多了的缘故吧
 
估计是 堆栈溢出
 
各位大侠:
不管这个程序有没有必要,关键是解决问题呀,请帮帮忙吧!
我用NuMega SmartCheck检测的结果是(程序一打开就关闭的情况下)
Program fault
Access Violation
Invalid read from 03B23D38
它的帮助里是这样写的
Description
A serious error, which has caused your program to shutdo
wn, has occurred.
There are many causes for this error. A couple possible causes and solutions
are described here:
?If your program executes successfully stand-alone, but gets an access
violation under SmartCheck, check the current setting of Overwrite memory
with a fill pattern upon de-allocation under Advanced Settings:

1 On the Program menu, click Settings.
2 On the Error Detection tab, click Advanced
If the setting is currently enabled, try disabling it, then
run your program
again. A subsequent, successful program run under SmartCheck indicates that
the access violation resulted from inappropriate memory referencing.
If the problem occurred in code to which you have no access,
such as a third-party control, contact the control vendor.
Leave the option disabled to continue checking your program with SmartCheck.
?An invalid handle exception indicates a bad handle was passed to the Win32
API function CloseHandle. This exception indicates a program error in a
component of the application, though the application continues to execute.
Note that the system only raises this exception for processes such as
SmartCheck that are started with the DEBUG_PROCESS flag. Therefore you will
see this exception when running your program under SmartCheck, but will not
see it when running the program in other contexts. For example, you will not
see the exception when running your program from the command-line.
请大家多多指点
 
高手,快帮帮忙呀!!!
多谢!!!
 
这个问题太复杂了,要具体情况具体分析,这和你的这几个人在编程时
是否协调一致有关,除非做到这些个模块一点关系都没有(你可以将所有的
模块将包编译进去的方式,这样做会使得程序大了不少,否则有可能会
发生不应该的错误),然后再逐个检查吧
 
修改所有的非主程序数据模块,增加一个TCustomRemoteServer变量和如下代码。
TDataModule = class(TDataModule)
SocketConnection1: TSocketConnection;
private
FRemoteServer: TCustomRemoteServer;
procedure SetRemoteConnect(const Value: TCustomRemoteServer);
public
property RemoteConnect: TCustomRemoteServer read FRemoteServer write SetRemoteConnect;
end;

procedure TDataModule.SetRemoteConnect(const Value: TCustomRemoteServer);
var i: Integer;
begin
FRemoteServer := Value;
for i:=0 to ComponentCount-1do
if Components is TClientDataSet then
(Components as TClientDataSet).RemoteServer := Value;
end;

主程序生成其它窗体时,把SocketConnection变量传递进去,其它的窗体生成自己的数据模块
时,把主程序给的SocketConnection赋值给数据模块的RemoteConnect属性。
这样就可以使用同一个远程连接了。
 
szf:
我会去试验你的代码,但这个错误是怎样产生的呢??我想知道你为什么这样做?
 
说不清楚。
 
建立一个大家都可以调用的数据模块,内有一个连接控件SOCKETCONNECTION,然后13个模块的
CLIENTDATASET 的REMOTESERVER 都指向该SOCKETCONNTION
 
我也遇到相同的问题,我暂时采用的是笨办法(因为我还想不到更好的办法),
就是不要在Destory事件里加任何代码,而是放在关闭窗体后:
if not assigned(WorkerForm) then
//是否还没创建
WorkerForm:=TWorkerForm.Create(Application);
//如没,那么创建
WorkerForm.ShowModal;
workerForm.Free;
workerForm:=nil;
 
to szf:
我试验你的代码,可是共有13个应用程序服务器,每个的名字都不相同,如何给
SocketConnection中的ServerName赋值呢??
 
to micro73:
你这样做可以解决问题吗???要是能解决,我可就要照着作了,想改好难呀,
有近两百个界面呀!
在线等
 
你可以试着改一两个界面,看看我说的对不对。
因为我也遇到你这样的问题,只要把 XXXXForm:=nil;等语句加入Destory事件中,
就经常会出错误,改成我所说的方法后,就没有这种问题。
我现在正在写一个人事工资系统,欢迎交流。 QQ:22662845,验证:delphi
 
我也遇到过您这样的问题。是不是还出现另一种提示。Access volitation.访问了无效的内
存区块呢?这个问题不好处理。大多与编程有关。绝对不是一二句话能搞定的。
 
to micro73:
我试了一下你的方法,但仍有错误,真的是好奇怪
你说的不要在Destroy里加任何东西,注释应该不算吧
还有,你在Close事件里加Action:=caFree了吗?
to billrobin:
好像是有.
 
不把 XXXXForm:=nil;等语句加入Destory事件中
不在Close事件里加Action:=caFree
试试!
 
我只是在主程序中的Close事件里加了Action:=caFree, 其它模块没加。
其实有些时候的问题是解释不清楚的,我遇到到相同的代码在一个窗口里行不通,
在另一个窗的中可以的怪问题。
你可以用少量的代码验证我的做法:
1)新建一个工程。
2)在form1中加入一个按钮。在Click事件中加入以下代码:
if not assigned(Form2) then
//是否还没创建
Form2:=TForm2。Create(Application);
//如没,那么创建
Form2.ShowModal;
Form2.Free;
Form2:=nil;
3)新增一个窗口form2。
4)在project-->option中取消form2的自动建立。
5)执行肯定没问题。
6)将form1中Button1的click事件中的
Form2.Free;
Form2:=nil;
转移到form2的destroy事件中,执行后出错“堆栈溢出”或“xxxxxxx地址只读”的错误。
注意:该程序最好不要直接在delphi中执行。
 
顶部