Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Processing loop runs out of memory or handles or somethi
Message
De
07/10/2013 12:15:49
 
 
À
07/10/2013 07:30:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01584860
Message ID:
01584914
Vues:
36
Thanks, Thomas. sys(1104) is exactly the one I was trying to think of - though I think Hilmar's noticing I was not closing tables is probably where I was blowing up.

It is throw away code in the sense that I would throw it away and write it better if I could remember enough VFP to do it right <g>

( It is rather like the man said about the mating of porcupines - "The amazing thing is not that it is done badly , but that it is done at all." )

It's been pretty much a sql server, C#, javascript world for the last dozen years and frankly every time I go back to VFP for something now I remember why I switched <g>

The help is appreciated - the group of folks here is the one thing I really do miss about VFP..


>Thinking mostly along the lines Hilmar already mentioned, but you may sprinkle in
>sys(1104)
>doevents
>wait window your_counter timeout 30
>doevents
>
>after closing each cursor and table pair in the loop which both should trigger a vfp garbage collection without slowing down too much. sys(3050) should not be a factor.
>
>I can clearly see that this is throw-away coding, but others would get ribbed for asking others to analyze such non-DRY code ;-)
>
>
>
>>I am processing 105 tables in a loop to create pipe separated text files to bulk insert to SQL
>>
>>Win 7 64 , 8gb ram. I make sure i boot clean and I'm seeing over 4gb available RAM. 30+ gb free on drive with VFP. Data files being processed are on another drive on the same box. Results going into directory on same drive as VFP.
>>
>>Below is the code. running the project in dev I crash with "there is not enough memory to complete this operation" though it seems to complete the operation as the tablesql has all the records and all the textfiles get created.
>>
>>I assume I am running out of file handles but I see available RAM going down to about 1.1 gb.
>>
>>Each trip through the outer loop) representing 1 table is independant so is there some way to release memory or file handles used by the processing in the loop before going on to the next one?
>>
>>Suggestions appreciated.
>>
>>
>>
>>USE tablesql IN 0 EXCLUSIVE
>>SELECT tablesql
>>DELETE ALL
>>PACK
>>PACK memo
>>
>>lcexppath = 'c:\users\public\sql\'
>>
>>lcpath=ADDBS(THIS.oparentbizobj.getfield("cpath_to_vfp"))+"convert"
>>SET DEFAULT TO (lcpath)
>>
>>lcsql = "SELECT  "
>>
>>lcdbc="inmatetrustfund.dbc"
>>
>>* ITERATE TABLES
>>
>>OPEN DATABASE (lcdbc) EXCLUSIVE
>>
>>ntables= ADBOBJECTS(latables,"TABLE")
>>
>>FOR i=1 TO ALEN(latables,1)
>>
>>	lcdbf=latables(i)
>>	lcalias=JUSTSTEM(lcdbf)
>>	
>>	SELECT tablesql
>>	APPEND BLANK
>>	REPLACE tablename WITH lcalias
>>
>>	WAIT WINDOW lcalias NOWAIT
>>	
>>	IF UPPER(lcalias) <> "SYSSETUP"
>>		USE (lcdbf) IN 0 EXCLU
>>
>>		SELECT (lcalias)
>>
>>		=AFIELDS(laflds)
>>		lnflds = ALEN(laflds,1)
>>		mcnt = 1
>>
>>*   SCAN FIELDS
>>
>>		FOR N=1 TO lnflds
>>
>>			lcfld=ALLTRIM(laflds(N,1))
>>			lctype=laflds(N,2)
>>			lnsize=laflds(N,3)
>>			llnct=laflds(N,6)
>>
>>			WAIT WINDOW lcalias + SPACE(10)+lcfld NOWAIT
>>
>>			SELECT (lcalias)
>>
>>			DO CASE
>>
>>			CASE INLIST(lctype,"D","T")
>>				
>>				lcsql = lcsql + " NVL(TTOC("+lcfld+",3),[1800-01-01])" + IIF(N < lnflds,',','')+lf
>>
>>			CASE (lctype="C" )
>>
>>				 lcsql = lcsql + " "+lcfld+ IIF(N < lnflds,',','')+ lf
>>
>>		 	CASE INLIST(lctype,'I','N','Y')
>>
>>			       lcsql = lcsql + " "+lcfld+IIF(N < lnflds,',','')+lf
>>
>>			 CASE (lctype = "L")
>>
>>				lcsql = lcsql + " IIF("+lcfld+"=.t.,1,0) "+IIF(N < lnflds,',','')+lf
>>
>>			CASE (lctype = "M")
>>
>>				 lcsql = lcsql + " IIF(LEN(ALLTRIM("+lcfld+")) < 220, STRTRAN("+lcfld+",CHR(13)+CHR(10),'@@'),'MCOL+"+ALLTRIM(STR(mcnt))+"') "+ IIF(N < lnflds,',','')+lf
>>
>>				  mcnt = mcnt+1
>>
>>			ENDCASE
>>
>>		ENDFOR  && field scan
>>
>>		lcsql = lcsql + " FROM "+ lcalias + " INTO CURSOR C_"+lcalias
>>
>>		&lcsql
>>
>>		lcname = "C_"+lcalias
>>
>>		 SELECT (lcname)
>>
>>		lcexpstr = [ COPY TO ']+lcexppath+lcname+[' DELIMITED WITH "" WITH CHARACTER '|' ]
>>
>>		 &lcexpstr
>>
>>		 SELECT tablesql
>>		 LOCATE FOR ALLTRIM(tablename) = lcalias
>>		 REPLACE mSQL WITH lcsql
>>
>>		lcsql = "SELECT " +lf
>>
>>	ENDIF
>>
>>ENDFOR && tablescan
>>
>>CLOSE DATABASE && inmatetrustfund
>>
>>**********************************************************************************************************************
>>
>>SET DEFAULT TO (lcdefa)
>>
>>RETURN
>>
>>


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform