Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


AutoAssemble.dll = Memory Hog ?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Zhoul
Master Cheater
Reputation: 1

Joined: 19 Sep 2005
Posts: 394

PostPosted: Wed Jan 18, 2006 10:58 am    Post subject: AutoAssemble.dll = Memory Hog ? Reply with quote

While in the middle of making the next big trainer, I noticed something very strange.

My mem usage at program launch, which was usually right around:


That may look pretty big at first, but most of it deals with the 2 embedded .bmp's used for the player map and the height-map (to find proper Z height of any point on the map).

If 10meg/4meg wasn't enough, I just noticed this:


I narrowed this down to the point in time where CEInitialize is called and the DLL loads.

A 50-megs-in-resident-memory-trainer = teh bad juujuu

Anything that can be done to conserve memory? This is nuts Cool

I'm still trying to work out if this is an issue I brought on myself or caused by the DLL, so I could just be a bastard for even bringing this up Wink I'll keep you informed on my findings.

- Zhoul
Back to top
View user's profile Send private message AIM Address
Zhoul
Master Cheater
Reputation: 1

Joined: 19 Sep 2005
Posts: 394

PostPosted: Wed Jan 18, 2006 12:09 pm    Post subject: Reply with quote

Further narrowed it down like so:

MsgBox "Just before memory hogging..."
CEInitialize ProcessID, ProcessHandle
MsgBox "Just after memory hogging..."

Right before I click Ok to the first message, 10meg/4meg.
Right after I click Ok on the first message, 30meg/24meg.
Back to top
View user's profile Send private message AIM Address
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25811
Location: The netherlands

PostPosted: Wed Jan 18, 2006 12:27 pm    Post subject: Reply with quote

thats possible if the game uses lots of dll's or debug symbols come with the package.

Just go back in the game and the memory will get paged out till it's needed again (only when scripts get executed with names it couldn't find in the registeredsymbol list or module list, it'll then have to use the symbollist)

also only call ceinitialize only once, other times call reinitialize

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Zhoul
Master Cheater
Reputation: 1

Joined: 19 Sep 2005
Posts: 394

PostPosted: Fri Jan 27, 2006 8:29 pm    Post subject: Reply with quote

There seems to be some sort of memory leak, related to repetitively enabling scripts which have no [enable] or [disable] tag. I noticed this after implementing a few scripts which have neither tag. I then ran more tests using different scripts, or partials, etc... In the end, same result (VM size grows and the rate is determined by how large the script is. About 8k/second with a 1 liner, and almost 25-50+k/second with longer scripts. The scripts are being force-written every 200ms

After enabling "[Enable]/[Disable]" scripts:


After enabling Script 1 and 2 (shown below) for about 15 minutes (to speed up the process a bit, I made 2 more copies of script 2 and enabled those as well).


Script 1: (8k every few seconds)
Code:
// Code - Insane Horsepower and Grip

00938704:
db 6F 12 03 3B


Script 2: (25k/second when enabled repetedly)
Code:
// Code - Give 1 of each marker (Visit shop after enabling).
// First 4 bytes: XX 00 00 00 - Where XX = Byte value of marker type
// Next 4 bytes 00 00 00 00 - Always 00 00 00 00
// Next 4 bytes 01 00 00 00 - Either 01 for 'not used' or 00 for 'used'
//
// Marker Types
// 01 - Preformance Upgrade - Brakes
// 02 - Preformance Upgrade - Engine
// 03 - Preformance Upgrade - Nitrous
// 04 - Preformance Upgrade - Turbo Charger
// 05 - Preformance Upgrade - Suspension
// 06 - Preformance Upgrade - Tires
// 07 - Preformance Upgrade - Transmission
// 08 - Custom Parts - Body
// 09 - Custom Parts - Hoods
// 0A - Custom Parts - Spoilers
// 0B - Custom Parts - Rims
// 0C - Custom Parts - Roof Scoops
// 0D - Custom Visual - Gauges
// 0E - Custom Visual - Vinyls
// 0F - Custom Visual - Decals
// 10 - Custom Visual - Paint
// 11 - Get Out Of Jail
// 12 -
// 13 -
// 14 - Impound Strike - Add Slot
// 15 - Release Car From Impound

0091D928:
db 01 00 00 00 00 00 00 00 01 00 00 00
0091D934:
db 02 00 00 00 00 00 00 00 01 00 00 00
0091D940:
db 03 00 00 00 00 00 00 00 01 00 00 00
0091D94C:
db 04 00 00 00 00 00 00 00 01 00 00 00
0091D958:
db 05 00 00 00 00 00 00 00 01 00 00 00
0091D964:
db 06 00 00 00 00 00 00 00 01 00 00 00
0091D970:
db 07 00 00 00 00 00 00 00 01 00 00 00
0091D97C:
db 08 00 00 00 00 00 00 00 01 00 00 00
0091D988:
db 09 00 00 00 00 00 00 00 01 00 00 00
0091D994:
db 0A 00 00 00 00 00 00 00 01 00 00 00
0091D9A0:
db 0B 00 00 00 00 00 00 00 01 00 00 00
0091D9AC:
db 0C 00 00 00 00 00 00 00 01 00 00 00
0091D9B8:
db 0D 00 00 00 00 00 00 00 01 00 00 00
0091D9C4:
db 0E 00 00 00 00 00 00 00 01 00 00 00
0091D9D0:
db 0F 00 00 00 00 00 00 00 01 00 00 00
0091D9DC:
db 10 00 00 00 00 00 00 00 01 00 00 00
0091D9E8:
db 11 00 00 00 00 00 00 00 01 00 00 00
0091D9F4:
db 12 00 00 00 00 00 00 00 01 00 00 00
0091DA00:
db 13 00 00 00 00 00 00 00 01 00 00 00
0091DA0C:
db 14 00 00 00 00 00 00 00 01 00 00 00
0091DA18:
db 15 00 00 00 00 00 00 00 01 00 00 00
0091DA24:
db 16 00 00 00 00 00 00 00 01 00 00 00

// - Extra Impound Strike Add Slot Markers
0091DA30:
db 14 00 00 00 00 00 00 00 01 00 00 00
0091DA3C:
db 14 00 00 00 00 00 00 00 01 00 00 00
0091DA48:
db 14 00 00 00 00 00 00 00 01 00 00 00
0091DA54:
db 14 00 00 00 00 00 00 00 01 00 00 00
0091DA60:
db 14 00 00 00 00 00 00 00 01 00 00 00


*Edit*
Think I found the issue:
The AllocID keeps increasing each time a Non enable/disable script is run. It was my understanding that -1 would be returned as an AllocID if the script weren't an enable/disable ? I went so far as to detect enable/disable scripts, and if the script were not, then immediately disable the script AllocID after it was enabled. This stopped the AllocID's from increasing each time, but memory was still being munched.

Can we get this bug fixed and have the AllocID return -1 if the script isn't an enable/disable script?

Thx!
Back to top
View user's profile Send private message AIM Address
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25811
Location: The netherlands

PostPosted: Sat Jan 28, 2006 6:50 pm    Post subject: Reply with quote

already fixed on the cvs, just not bothered uploading it yet. (you can give allocid NULL or the value of allocid -1 and it'll stop allocating)

but have you tried imeadiatly calling the disable function for that script ? (empty script with the returned allocid with "enable" set to false)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Zhoul
Master Cheater
Reputation: 1

Joined: 19 Sep 2005
Posts: 394

PostPosted: Sat Jan 28, 2006 8:05 pm    Post subject: Reply with quote

Dark Byte wrote:
but have you tried imeadiatly calling the disable function for that script ? (empty script with the returned allocid with "enable" set to false)

Zhoul wrote:
I went so far as to detect enable/disable scripts, and if the script were not, then immediately disable the script AllocID after it was enabled. This stopped the AllocID's from increasing each time, but memory was still being munched.

Code:
Public Function Assemble_Script(strPassedScript As String, bolPassedEnable As Variant, intPassedAllocID As Variant, lngPassedScriptNum As Variant) As Long
< buncha code between here >

    bolWriteSuccess = CEAutoAsm(script, enable, allocid)
    If bolWriteSuccess = False Then
        Assemble_Script = -1
    Else
        Assemble_Script = allocid
    End If
   
    If (enable And bolWriteSuccess And lngPassedScriptNum <> -1) Then
        If (CheckEnableScript(script) = True) Then
            lngAllocID(lngPassedScriptNum) = allocid
        Else
            If (allocid <> -1) Then
                CEAutoAsm script, False, allocid
            End If
            lngAllocID(lngPassedScriptNum) = -1
        End If
    Else
        lngAllocID(lngPassedScriptNum) = -1
    End If
< More code after >

Above: I'm not passing a blank script, but the same script that I just used. I wouldn't think this should matter, eh?


DB wrote:
(you can give allocid NULL or the value of allocid -1 and it'll stop allocating)

Would it not be safer to have the DLL control the entirety of the return value of AllocID? This could easily be controlled internally, by writing a boolean=true, *when* the DLL allocates memory. If boolean=false at the return point, then AllocID = -1 .

The other way to approach it (preferred) would be to simply check incoming scripts for the [enable] tag, and if not exist, then AllocID = -1 . I'm assuming, at some point in your code, that you detect the [enable] tag. At this point, you could set boolean=true.

But if not: Below is the code I use to figure out if a script is an enable script or not. It weeds out any [enable] tag that has a "/" or " " before it and assumes the tag is commented. (i.e. // [Enable] and //[Enable] would be ignored). While it's not delphi, I'm sure it can easily be converted.

Code:
Public Function CheckEnableScript(ByVal strScript As String) As Boolean
On Error GoTo EH
Dim i As Integer
Dim bolEnableScript As Boolean
Dim bolCommented As Boolean
Dim strCurChar As String, strLastChar As String
Dim strEnable As String

    If (Len(strScript) = 0) Then Exit Function

    For i = 1 To Len(strScript)
        strCurChar = UCase(Mid(strScript, i, 1))
        Select Case strCurChar
            Case Is = "[", "E", "N", "A", "B", "L", "]"
                If (strCurChar = "[") Then
                    strEnable = strCurChar
                Else
                    strEnable = strEnable & strCurChar
                End If
                If (UCase(strEnable) = "[ENABLE]" And bolCommented = False) Then
                    CheckEnableScript = True
                    Exit Function
                End If
            Case Is = "/"
                If (strLastChar = "/" Or strLastChar = " ") Then
                    bolCommented = True
                End If
        End Select
        If (strLastChar & strCurChar = vbNewLine) Then
            bolCommented = False
        End If
        strLastChar = strCurChar
    Next i

    CheckEnableScript = False

Exit Function
EH:
MsgBox "An error occured while in the CheckEnableScript function." & vbNewLine & "Error Number: " & Err.Number & vbNewLine & "Error Description: " & Err.Description
End Function

It should be noted that vbNewLine is 2 characters. Chr(13) & Chr(10)

Either way it goes, IMHO, AllocID return when enabling scripts, is logically handled better by the DLL. It'd save future users of it a few coding headaches as well Wink

Also, what happens now: If we enable an alloc style script, but also pass a null or -1 ?

Lastly: If you decide not to handle AllocID in enable scripts entirely via DLL, wouldn't it be wise to only accept null and not -1 for AllocID ? If someone uses a loop to mass enable a bunch of scripts, they are going to use a single variable to capture the AllocID in. If a script fails or doesn't allocate memory, that variable is set to -1 . On next loop, the same variable is being used to capture the next AllocID, but because it's -1 from the last run, it will h0ze the processing of an alloc script, because CEAutoASM thinks you're trying to tell it to not allocate memory, when you're just trying to capture the AllocID. In this case, we'd have to simply set Allocid = 0 on each loop, but that doesn't make any logical sense Wink

- Zhoul


Last edited by Zhoul on Sat Jan 28, 2006 8:37 pm; edited 1 time in total
Back to top
View user's profile Send private message AIM Address
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25811
Location: The netherlands

PostPosted: Sat Jan 28, 2006 8:36 pm    Post subject: Reply with quote

here is the most recent version

if you pass a NULL pointer instead of a pointer to a 4byte address it will disregard all memory allocations in the script and not save them internally.
if you pass a pointer to a variable, but it's value is -1, it will then also disregard all memory allocations, so be sure your allocid is initialized to at least 0, or a allocid of a previous allocation

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Zhoul
Master Cheater
Reputation: 1

Joined: 19 Sep 2005
Posts: 394

PostPosted: Sat Jan 28, 2006 9:11 pm    Post subject: Reply with quote

Code:
Dim intAllocID as Variant
intAllocID = Null
CEAutoASM (script, True, intAllocID)

"Invalid Use of Null"

Code:
Dim intAllocID as Variant
intAllocID = -1
CEAutoASM (script, True, intAllocID)

While this does enable the script, it also creates an AllocID and returns it to intAllocID.

It's also still growing in memory when repetitively enabling a script.

Functions *exactly* like the previous one I had. Is *exactly* the same size, just different modified date. In fact, all 4 versions I have are exactly the same size. Not sure if this matters Wink

/shrug
Back to top
View user's profile Send private message AIM Address
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25811
Location: The netherlands

PostPosted: Sun Jan 29, 2006 7:04 am    Post subject: Reply with quote

try CEAutoASM (script, True, null)
seems I was wrong regarding the -1 value, that was being ignored after all

see if you can get VB to give as last parameter a NULL pointer. (if you can't figure it out, then declare it as a standard integer by val and give as value 0)

And yes, the size probably stays the same as long as I don't add or take more than 4kb code

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Zhoul
Master Cheater
Reputation: 1

Joined: 19 Sep 2005
Posts: 394

PostPosted: Sun Jan 29, 2006 6:13 pm    Post subject: Reply with quote

Dark Byte wrote:
see if you can get VB to give as last parameter a NULL pointer. (if you can't figure it out, then declare it as a standard integer by val and give as value 0)
I've aleady tried many variations (including this one). Just didnt post the 5-10 ways I've tried. Still, an invalid use of null.

Have you tried this yet ?

I recommend making a loop that calls a non-enable/disable script and seeing if mem increases over time. It doesn't take long, especially if you use the longer script I posted above (or something similar).
Back to top
View user's profile Send private message AIM Address
Leonidas
Advanced Cheater
Reputation: 0

Joined: 07 Mar 2005
Posts: 98

PostPosted: Mon Jan 30, 2006 2:04 am    Post subject: Reply with quote

I did, but this new dll doesn't take up more ram when giving null.
I injected the routine:
Code:

00400500:
nop
nop
nop
nop
nop


5000 times with allocid null and it ended with about the same memory usage as before calling
make sure the pointer is null, and not the variable it points to
Back to top
View user's profile Send private message
Zhoul
Master Cheater
Reputation: 1

Joined: 19 Sep 2005
Posts: 394

PostPosted: Mon Jan 30, 2006 2:44 am    Post subject: Reply with quote

! Ding !

Old Declare:
Public Declare Function CEAutoAsm Lib "ceautoassembler.dll" (ByVal script As String, ByVal enable As Boolean, ByRef AllocID As Integer) As Boolean

New Declare:
Public Declare Function CEAutoAsm Lib "ceautoassembler.dll" (ByVal script As String, ByVal enable As Boolean, ByRef AllocID As Variant) As Boolean

Embarassed Cool

Tested and it works perfectly.

*Edit*

After much toil and info on the DLL from DB.... the end result is...

Code:

Public Function Assemble_Script(strPassedScript As String, Optional bolPassedEnable As Boolean = True, Optional varPassedAllocID As Variant = Null, Optional intPassedScriptNum As Variant = -1, Optional bolDisableFirst As Boolean = True) As Boolean
On Error GoTo EH
Dim i As Integer
'---- Below 3 specifically used for passing arguments to CEAutoASM
Static Script As String
Static Enable As Boolean
Dim AllocID As Variant
'---- bolWriteSuccess catches the True/False from CEAutoASM
'---- True = Script Enable/Disable was successful
'---- False = Script Enable/Disable was unsuccessful
Dim bolWriteSuccess As Boolean

    ' If there is no process handle...
    ' - Set DLL connectivity if there is no process handle.
    ' - Set Assemble_Script = False
    ' - Exit the function
    If (ProcessHandle = 0) Then
        If (CEInit() = False) Then
            Exit Function
        End If
    End If
   
    ' script
    If (strPassedScript = "") Then
        Exit Function
    Else
        Script = strPassedScript
    End If
   
    Enable = bolPassedEnable
   
    ' Ensure the DLL has been initiated.
    If (CEInit() = False) Then
        Exit Function
    End If
   
    ' intPassedScriptNum
    If (IsNull(intPassedScriptNum)) Then
        intPassedScriptNum = -1
    Else
        If (intPassedScriptNum < intScriptLBound Or intPassedScriptNum > intScriptUBound) Then
            intPassedScriptNum = -1
        End If
    End If
   
    If (IsEmpty(varPassedAllocID) = False And IsNull(varPassedAllocID) = False And IsNumeric(varPassedAllocID)) Then
        AllocID = CLng(varPassedAllocID)
    Else
        If (IsEmpty(varPassedAllocID)) Then
            If (CheckEnableScript(Script)) Then
                AllocID = CLng(-1)
            Else
                AllocID = Null
            End If
        Else
            AllocID = Null
        End If
    End If

    ' If bolDisablefirst = True
    ' If enable = True
    ' If a script number was passed
    ' If a script is already enabled, disable it before enabling
    If (bolDisableFirst And Enable And Not intPassedScriptNum = -1) Then
        If (AllocID > -1 And Not IsNull(AllocID)) Then
            CEAutoAsm Script, False, varAllocID(intPassedScriptNum)
        End If
    End If
     
    If (IsNull(AllocID)) Then
        bolWriteSuccess = CEAutoAsm(Script, Enable, 0&)
    Else
        bolWriteSuccess = CEAutoAsm(Script, Enable, AllocID)
    End If
   
    If (intPassedScriptNum <> -1) Then
        If (IsNull(AllocID) Or Enable = False) Then
            varAllocID(intPassedScriptNum) = Empty
        Else
            varAllocID(intPassedScriptNum) = AllocID
        End If
    End If
   
    Assemble_Script = bolWriteSuccess

Exit Function
EH:
MsgBox "An error occured while in the Assemble_Script function." & vbNewLine & "Error Number: " & Err.Number & vbNewLine & "Error Description: " & Err.Description
Resume Next
End Function


/sighs
Back to top
View user's profile Send private message AIM Address
Zhoul
Master Cheater
Reputation: 1

Joined: 19 Sep 2005
Posts: 394

PostPosted: Tue Apr 25, 2006 1:26 am    Post subject: Reply with quote

It seems that the .dll isn't the only memory hog. It appears that; Trainers created by CE that use an auto assemble script, also experience the huge memory consumption. Not sure if this is at all 'fixable', but 50 meg trainers are a bit much, eh?

I've included the .ct I used to make a trainer (for TES: Oblivion). There's only 1 auto assemble script in the cheat table itself.

- Zhoul



Oblivion-Trn-TaskManager.JPG
 Description:
 Filesize:  68.72 KB
 Viewed:  17103 Time(s)

Oblivion-Trn-TaskManager.JPG



Oblivion.CT
 Description:

Download
 Filename:  Oblivion.CT
 Filesize:  2.15 KB
 Downloaded:  1330 Time(s)

Back to top
View user's profile Send private message AIM Address
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25811
Location: The netherlands

PostPosted: Tue Apr 25, 2006 1:56 am    Post subject: Reply with quote

I don't take you have the microsoft windows symbol files installed on your system right? Because debuginformation and stuff like that will get stored in a internal database in the trainer. And the mmore it can find (e.g windows symbols) the more it'll store
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites