Memory leak when printing report from VB

G

Guest

I have a system that sends 1 rec of data to access once an hour and once a day using ODBC.
The system also prints a report once an hour and day using VB script (DoCmd.OpenReport).
The system locks up about every 5 days so I ran the performance monitor and discovered that it runs out of memory.
Every hour when the report prints, a small chunk of memory is lost. I went thru my code and all my objects are destroyed (set to Nothing). I commented out the one line that does the printing (OpenReport command) and everything worked fine. no memory lost. Anybody know why the OpenReport command may be eating memory? Is ther another way to print Access reports through VB?
 
S

Suzette

Are you closing the report after opening it? It's just a thought.

JES100 said:
I have a system that sends 1 rec of data to access once an hour and once a day using ODBC.
The system also prints a report once an hour and day using VB script (DoCmd.OpenReport).
The system locks up about every 5 days so I ran the performance monitor
and discovered that it runs out of memory.
Every hour when the report prints, a small chunk of memory is lost. I went
thru my code and all my objects are destroyed (set to Nothing). I commented
out the one line that does the printing (OpenReport command) and everything
worked fine. no memory lost. Anybody know why the OpenReport command may be
eating memory? Is ther another way to print Access reports through VB?
 
R

rainerschulz

Hi, I have nearly the same problem.

With every Printout I loose about 80 KB of Memory. I use Access 97.

Do you have a "simple" Access Report? Because I have also some heav
VB-Code within my Report (to format it and so on....).

I have Service Pack 2b installed.

May be we can work a little bit togehter, to fix this problem.

Also my pc crashes after a couple of days.
If discovered so far, that access97/windows allocates memory i
irregular steps:
1 MB
2 MB ==> 3 MB TOTAL
4 MB ==> 7 MB TOTAL
64 MB ==> 71 MB TOTAL (High Chance of first crash!)
8 MB ==> 79 MB TOTAL
????

I used the GlobalMemoryStatus Method of the kernel32 to get thi
information....
My Performance-Monitor results, was unaccaptable, because I did not ge
it to the point, to record really the Memory-Affect.

Additionally Access97 does only check for PHYSICAL Memory (which i
quite unusual).

Additionally, a quite similar problem is known with forms i
Access2000:
http://tinyurl.com/yqlkp

Raine


-
rainerschul
 
R

rainerschulz

Hey, I did find the reason (sorry for my broken english - I am Germa
and quality depends on the local time. Late at night it gets worse an
worse..).

The reason has NOTHING to do with access (not directly). It was th
printer driver.

I did use leadTools eprint to generate the PDF-Files.
Already in the preview, it did take about 2 kB per Page.

Thats it. Different selected printer, no problem.

Raine


-
rainerschul
 
T

Tony Toews

rainerschulz said:
With every Printout I loose about 80 KB of Memory. I use Access 97.

Stephen Lebans recently informed us that using the OnPrint event
rather than the OnFormat event has been suggested by Microsoft's tech
support to alleviate running out of memory or system resources when
printing images.

Stephen Lebans has stated that Microsoft has determined that the
long-time problem of leaking memory in reports using image controls
does not occur if the image files are .BMP.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
S

Stephen Lebans

Hi Tony,
conversion of the Image to Bitmap prior to insertion into the Image
control alleviates the "out of memory" error in Print Preview and seems
to completely remove the "out of memory" error when actually printing
the report.

Here is the code I use to convert any Jpeg, Gif, or Metafile into a BMP.
Rather than using one of my API solutions I have cheated and set a
Reference to Standard OLE Types type library in order to get at the
SAVETODISK method. But no ActiveX controls are required


Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Private ctr As Long

ctr = ctr + 1

Select Case ctr
Case 1
Me.Image10.Picture = CreateBitmapFile("C:\A.jpg")

Case 2
Me.Image10.Picture = CreateBitmapFile("C:\b.jpg")

Case 3
Me.Image10.Picture = CreateBitmapFile("C:\c.jpg")
ctr = 0

Case Else
ctr = 0

End Select

End Sub

Private Sub Report_Open(Cancel As Integer)
ctr = 0
End Sub


Private Function CreateBitmapFile(fname As String) As String

Dim obj As Object

Set obj = LoadPicture(fname)
If Not IsNull(obj) Then

SavePicture obj, "C:\SL11-52"
DoEvents
End If


CreateBitmapFile = "C:\SL11-52"
Set obj = Nothing

End Function


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top