| | |
|
|
|
Re: Memory leak when printing report from VB |
| message from rainerschulz on 15 May 2004 |
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 heavy
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 in
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 this
information....
My Performance-Monitor results, was unaccaptable, because I did not get
it to the point, to record really the Memory-Affect.
Additionally Access97 does only check for PHYSICAL Memory (which is
quite unusual).
Additionally, a quite similar problem is known with forms in
Access2000:
http://tinyurl.com/yqlkp
Rainer
|
| Tony Toews replied to rainerschulz on 16 May 2004 |
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
|
| Stephen Lebans replied to Tony Toews on 16 May 2004 |
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
|
| rainerschulz replied to rainerschulz on 16 May 2004 |
Hey, I did find the reason (sorry for my broken english - I am German
and quality depends on the local time. Late at night it gets worse and
worse..).
The reason has NOTHING to do with access (not directly). It was the
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.
Rainer
|
|
Archived message: Re: Memory leak when printing report from VB (Microsoft Access Database)