home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form haForm
- BackColor = &H00808000&
- BorderStyle = 1 'Fixed Single
- Caption = "Heap Alert 1.1"
- ClientHeight = 2100
- ClientLeft = 600
- ClientTop = 3600
- ClientWidth = 2160
- Height = 2505
- Icon = HA.FRX:0000
- Left = 540
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 2100
- ScaleWidth = 2160
- Top = 3255
- Width = 2280
- Begin CommandButton getInfo
- BackColor = &H00808000&
- Caption = "&Sample"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 375
- Left = 1260
- TabIndex = 26
- Top = 1620
- Width = 795
- End
- Begin CheckBox autoSample
- BackColor = &H00808000&
- Caption = "&Auto"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 255
- Left = 1380
- TabIndex = 27
- Top = 1200
- Value = 1 'Checked
- Width = 675
- End
- Begin Timer sampleTimer
- Interval = 4000
- Left = 1440
- Top = 720
- End
- Begin Label disabledDCCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 29
- Top = 2700
- Width = 375
- End
- Begin Label Label7
- BackColor = &H00808000&
- Caption = "DisDCs:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 33
- Top = 2700
- Width = 735
- End
- Begin Label metaDCCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 28
- Top = 2520
- Width = 375
- End
- Begin Label Label4
- BackColor = &H00808000&
- Caption = "MetaDCs:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 32
- Top = 2520
- Width = 735
- End
- Begin Label metafileCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 24
- Top = 2340
- Width = 375
- End
- Begin Label Label18
- BackColor = &H00808000&
- Caption = "Metafiles:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 16
- Top = 2340
- Width = 735
- End
- Begin Label otherCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 30
- Top = 1860
- Width = 375
- End
- Begin Label Label6
- BackColor = &H00808000&
- Caption = "Other:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 31
- Top = 1860
- Width = 735
- End
- Begin Label penCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 21
- Top = 1680
- Width = 375
- End
- Begin Label Label15
- BackColor = &H00808000&
- Caption = "Pens:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 13
- Top = 1680
- Width = 735
- End
- Begin Label paletteCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 25
- Top = 1500
- Width = 375
- End
- Begin Label Label19
- BackColor = &H00808000&
- Caption = "Palettes:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 17
- Top = 1500
- Width = 735
- End
- Begin Label regionCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 23
- Top = 1320
- Width = 375
- End
- Begin Label Label17
- BackColor = &H00808000&
- Caption = "Regions:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 15
- Top = 1320
- Width = 735
- End
- Begin Label brushCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 22
- Top = 1140
- Width = 375
- End
- Begin Label Label16
- BackColor = &H00808000&
- Caption = "Brushes:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 14
- Top = 1140
- Width = 735
- End
- Begin Label dcCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 20
- Top = 960
- Width = 375
- End
- Begin Label Label14
- BackColor = &H00808000&
- Caption = "DCs:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 12
- Top = 960
- Width = 735
- End
- Begin Label bitmapCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 19
- Top = 780
- Width = 375
- End
- Begin Label Label13
- BackColor = &H00808000&
- Caption = "Bitmaps:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 11
- Top = 780
- Width = 735
- End
- Begin Label fontCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 18
- Top = 600
- Width = 375
- End
- Begin Label Label12
- BackColor = &H00808000&
- Caption = "Fonts:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 10
- Top = 600
- Width = 735
- End
- Begin Label gdiPercent
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 1740
- TabIndex = 7
- Top = 420
- Width = 375
- End
- Begin Label gdiBytes
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 1200
- TabIndex = 5
- Top = 420
- Width = 495
- End
- Begin Label gdiCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 9
- Top = 420
- Width = 375
- End
- Begin Label Label2
- BackColor = &H00808000&
- Caption = "GDI:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 1
- Top = 420
- Width = 735
- End
- Begin Label userPercent
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 1740
- TabIndex = 6
- Top = 240
- Width = 375
- End
- Begin Label userBytes
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 1200
- TabIndex = 4
- Top = 240
- Width = 495
- End
- Begin Label userCount
- Alignment = 1 'Right Justify
- BackColor = &H00808000&
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 8
- Top = 240
- Width = 375
- End
- Begin Label Label1
- BackColor = &H00808000&
- Caption = "User:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 60
- TabIndex = 0
- Top = 240
- Width = 735
- End
- Begin Label Label8
- BackColor = &H00808000&
- Caption = "Free:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 1740
- TabIndex = 34
- Top = 60
- Width = 375
- End
- Begin Label Label3
- Alignment = 2 'Center
- BackColor = &H00808000&
- Caption = "Used:"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 1200
- TabIndex = 2
- Top = 60
- Width = 495
- End
- Begin Label Label5
- Alignment = 2 'Center
- BackColor = &H00808000&
- Caption = "#"
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 195
- Left = 780
- TabIndex = 3
- Top = 60
- Width = 375
- End
- Sub autoSample_Click ()
- If autoSample.value = 1 Then
- sampleTimer.enabled = -1
- Else
- sampleTimer.enabled = 0
- End If
- End Sub
- Sub Form_Load ()
- V& = GetVersion()
- WindowsVersion% = V& And 65535
- Major% = WindowsVersion% And 255
- Minor% = (WindowsVersion% / 256) And 255
- If Major% >= 3 And Minor% >= 10 Then
- screen.mousePointer = 11
- iUserHeap% = 0
- iGDIHeap% = 0
- haForm.left = 0
- haForm.top = 0
- Call retrieveData
- screen.mousePointer = 0
- Else
- MsgBox "Heap Alert 1.1 Requires at least Windows 3.1 commercial."
- End
- End If
- End Sub
- Sub getInfo_Click ()
- Call retrieveData
- End Sub
- Function makeLong (ByVal i%) As Long
- ' Visual Basic needs unsigned integers!
- If i% < 0 Then
- makeLong = CLng(32767) + (CLng(32769) + CLng(i%))
- Else
- makeLong = CLng(i%)
- End If
- End Function
- Sub retrieveData ()
- Dim le As sLOCALENTRY
- Dim sh As sSYSHEAPINFO
- Dim ge As sGLOBALENTRY
- ' initialize the sizes of these structures
- le.dwSize = Len(le)
- sh.dwSize = Len(sh)
- ge.dwSize = Len(ge)
- iFonts% = 0
- iBitmaps% = 0
- iDCs% = 0
- iPens% = 0
- iBrushes% = 0
- iRegions% = 0
- iMetafiles% = 0
- iPalettes% = 0
- iMetaDC% = 0
- iDisabledDC% = 0
- iOther% = 0
- gb& = 0
- gc& = 0
- ub& = 0
- uc& = 0
- r% = SystemHeapInfo(sh)
- ' find the User and GDI heaps, but only the first time
- ' in 3.0 the heaps are 1 greater than sh.hX
- ' in 3.1 the heaps are 1 less than sh.hX
- If iUserHeap% = 0 Or iGDIHeap% = 0 Then
- r% = GlobalFirst(ge, GLOBAL_ALL)
- While r% <> 0 And (iUserHeap% = 0 Or iGDIHeap% = 0)
- If ge.wHeapPresent = 1 Then
- q% = LocalFirst(le, ge.hBlock)
- If le.wHeapType = USER_HEAP Then
- iUserHeap% = ge.hBlock
- ElseIf le.wHeapType = GDI_HEAP Then
- iGDIHeap% = ge.hBlock
- End If
- End If
- r% = GlobalNext(ge, GLOBAL_ALL)
- Wend
- End If
- ' walk the User heap
- If iUserHeap% <> 0 Then
- q% = LocalFirst(le, iUserHeap%)
- While q% <> 0
- If le.wFlags <> LF_FREE Then
- uc& = uc& + 1
- ub& = ub& + makeLong(le.wSize)
- End If
- q% = LocalNext(le)
- Wend
- End If
- ' walk the GDI heap
- If iGDIHeap% <> 0 Then
- q% = LocalFirst(le, iGDIHeap%)
- While q% <> 0
- If le.wFlags <> LF_FREE Then
- gc& = gc& + 1
- gb& = gb& + makeLong(le.wSize)
- Select Case le.wType
- Case LT_GDI_FONT
- iFonts% = iFonts% + 1
- Case LT_GDI_BITMAP
- iBitmaps% = iBitmaps% + 1
- Case LT_GDI_DC
- iDCs% = iDCs% + 1
- Case LT_GDI_PEN
- iPens% = iPens% + 1
- Case LT_GDI_BRUSH
- iBrushes% = iBrushes% + 1
- Case LT_GDI_RGN
- iRegions% = iRegions% + 1
- Case LT_GDI_METAFILE
- ' for some reason, 3.1 counts metafiles as "other"
- iMetafiles% = iMetafiles% + 1
- Case LT_GDI_PALETTE
- iPalettes% = iPalettes% + 1
- Case LT_GDI_METADC
- iMetaDC% = iMetaDC% + 1
- Case LT_GDI_DISABLED_DC
- iDisabledDC% = iDisabledDC% + 1
- Case LT_NORMAL
- iOther% = iOther% + 1
- End Select
- End If
- q% = LocalNext(le)
- Wend
- End If
- gdiCount.caption = LTrim$(Str$(gc&))
- userCount.caption = LTrim$(Str$(uc&))
- gdiBytes.caption = LTrim$(Str$(gb&))
- userBytes.caption = LTrim$(Str$(ub&))
- fontCount.caption = LTrim$(Str$(iFonts%))
- bitmapCount.caption = LTrim$(Str$(iBitmaps%))
- dcCount.caption = LTrim$(Str$(iDCs%))
- penCount.caption = LTrim$(Str$(iPens%))
- brushCount.caption = LTrim$(Str$(iBrushes%))
- regionCount.caption = LTrim$(Str$(iRegions%))
- metafileCount.caption = LTrim$(Str$(iMetafiles%))
- paletteCount.caption = LTrim$(Str$(iPalettes%))
- metaDCCount.caption = LTrim$(Str$(iMetaDC%))
- disabledDCCount.caption = LTrim$(Str$(iDisabledDC%))
- otherCount.caption = LTrim$(Str$(iOther%))
- ' not sure why these numbers don't come out the same.
- ' according to the documentation they should.
- 'userPercent.caption = LTrim$(Str$(100-CInt(100 * CSng(ub&) / 65536!))) + "%"
- 'gdiPercent.caption = LTrim$(Str$(100-CInt(100 * CSng(gb&) / 65536!))) + "%"
- userPercent.caption = LTrim$(Str$(sh.wUserFreePercent)) + "%"
- gdiPercent.caption = LTrim$(Str$(sh.wGDIFreePercent)) + "%"
- End Sub
- Sub sampleTimer_Timer ()
- Call retrieveData
- End Sub
-