[ Midtown Madness 2 Central ] [ Midtown Madness 2 Central ]

Midtown Madness 2 Central > City Editing > Finding the memory limits / Cause of Heap overrun error
Goto page 1, 2  Next
View previous topic | View next topic
Author
Message Post new topicReply to topic
Lex_Luther
Waterboy

Joined: 11 Jan 2008
Posts: 18


Status: Offline


Post subject: Finding the memory limits / Cause of Heap overrun error Reply with quote

I've been working with The New York map for a while now, and have come to realise a few things about the game's memory usage. In particular, How to avoid the dreaded "Heap overrun".

What I learned from my 'old' experiment:
---- Props are the worst memory hogs- memory is used for each UNIQUE item PER BLOCK.
For example Having 100 phone booths in one block uses the
memory for just 1-- but having 100 phone booths each in it's own block uses the memory of 100
---- INST only uses memory for each UNIQUE item placed regardless of it's block. So putting the same item in a hundred times only uses the memory of 1.
This rule also applies to cars. If everyone takes the same car it's much
better on memory.

---- Lowering the screen resolution frees up this heap/stack memory.


I wanted to know more about the game's limits, so I did a few more
experiments:

Experiment #1- How many polygons can be loaded in a city? I made an
empty map, then made a 10,000 poly cone, with a tiny 6 poly bound. Copied the file 200 times to make 200 uniquely named pkg and bnd files.
Results:
at 1280x1024- 97 cones loaded, but 98 crashed it
1152 100-101
1024 101-102
800 108-109
640 109-110

So at 1024x768 the game can load 1,010,000 polys.

The game would load fine, but if I got to a place with too many polys on
the screen, the game would crash to desktop.

--I repeated the above, but with an enourmous cone. Results were the same. Size really doesn't matter-- it's the count that counts.

--I also tried with different sized textures- no difference. (although I
suspect the frame rate would take a big hit w/ a big texture)

--Tried again thinking the game only cared about the H. So I made a cone
with a 5k H and a 5K M and the results were the same. -- So all bodies in
the pkg are counted towards the limit (H M L VL, etc.)


Experiment #2 - the bound test.
I made a cone with a 6 poly H, 6 poly VL, and 10,000 poly BOUND. Renamed it to 200 unique names, and placed them until it crashed. Didn't take long:

1152&1024 17 would load, 18 crashed it
800x600 18 loaded.

Wow this sucks! Bounds use up over 5 times as much precious stack memory than a regular poly. I repeated the test but with a 5k BOUND. results were the same:
1280 32
1024/1152 34
800 - 36
Please note that the bounds give a slightly different heap overrun
message:
Heap overrun [datCurrentMemoryAlign=4]


Conclusion: the game can handle only 170,000 polys of BOUNDs. (but this
doesn't leave any mem left for the pkgs to be drawn)


Using this knowledge, I approximated the mem use for new york:
PSDL (20k)+
pkg (680k) +
Bound(300k) +
Free (10k)
======
1010k (@ 1024x178)


---------------------------------------------------------------------
I'm picturing a "Lego block City" built up from just a small number of
pkgs, each with multiple paint jobs. making possible to build walls, roads,
and buildings all using hardly any memory.
------------------------------------------------------------------------


Memory saving tips when making a new object or city:
-- Keep the poly count low for the H
-- Make sure the VL really is very low Don't be Lazy and copy the H for everything
-- Never let the bound be more than 15% of the H. And for the love of God, don't just copy the H! (although I admit, I've done this before. But am going back and redoing them all)
-- Try to use each pkg more than once in your city.

------------------------------------------------------------------------------
I didn't tinker around with peds/ traffic, but I figure similar rules apply.
Anyone who wants to tinker with it more, let me know the results. If anyone out there that has cracked into the inst, pkg, bbnd, bnd, and ter formats that wants to make a program to count up the mem usage that would be an awesome tool. Even a prog to sort the inst would be helpful.

HOPE THIS INFO HELPS
Post 07 May 2008 10:04 pm
View user's profile Send private message
HummersRock
...is still seeing colours.

Joined: 20 Feb 2006
Posts: 2669
Location: Magic Mushroom Land

Status: Offline


Post subject: Reply with quote

Nice finds man. Thumbs Up

The bound is that bad? Wow, well, from now on I guess I'll be doing custom bound and making it as low poly as possible then. Surprised

Keep it up man, we need more people like you. Wink

I'll keep this stuff in mind. Wink
_________________
My MM2 Creations | My DeviantArt
Post 08 May 2008 01:12 am
View user's profile Send private message Send e-mail Visit poster's website
b12man
Nirvanophile

Joined: 07 Aug 2006
Posts: 2153
Location: Lurking somewhere near...

Status: Offline


Xbox Live Gamertag:
ForeignBrian 12
Post subject: Reply with quote

That's amazing! Thanks for doing this.
I'm sure it'll help a ton of people.
_________________


Tutorials || Make Your Own Traffic | Change Traffic Tuning
Projects || 93 Mustang GT | 85 Chevy Suburban [WIP]
Post 08 May 2008 01:26 am
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
thenthornthing
MM2C Hooligan

Joined: 18 Jan 2007
Posts: 4409


Status: Offline


Post subject: Reply with quote

Wow, i think i'll be changing a few of my files in future.
_________________
So it's "Goodnight" from me. And it's "Goodnight" from him. Goodnight!
Post 08 May 2008 05:55 am
View user's profile Send private message Send e-mail
ITN_Tuning
a.k.a. Jaguara

Joined: 21 Oct 2006
Posts: 537
Location: Rousse,Bulgaria

Status: Offline


Post subject: Reply with quote

Hmm..i gotta change my way of creating cities for MM2 then. Thank you
for the precious info, man.
_________________
Post 08 May 2008 09:07 am
View user's profile Send private message Send e-mail Visit poster's website
I'm 359
Waterboy

Joined: 22 Mar 2008
Posts: 8


Status: Offline


Post subject: Reply with quote

sorry but i just want to ask, is "poly" equal to "faces" in ZM?
And is it means that "placing the same pkg by props in different PSDL" will use more memory than" placing the same pkg by INST in different PSDL" ?
Post 08 May 2008 10:29 am
View user's profile Send private message
Riva
Rivalicious

Joined: 29 Jan 2003
Posts: 1130
Location: Belgium

Status: Offline


Post subject: Reply with quote

I've noticed for all these years that to export a BODY_H (from ZModeler 1.07b) having more than 65k vertices didn't work in-game (stopped loading), independently other objects. e.g. the high poly models of SheryO and César didn't work except when I use detachable parts to reduce the body. No limit for the wheels. I'm pretty sure that it there not a polys (or faces or triangles, same things for ZM) limit except the system requirements of each one contrary to this limit of vertices imposed by ZM. I had contacted Oleg about it but alas no update for the PKG plugin. Maxoff improved this one for other reasons (reflection management, more export paintings, etc), I don't know if he's able to increase this vertices limit.

Of course I tested many cars (Ferrari Enzo, Jaguar XJ220, Porsche Carrera GT, differents Scania, some Renault Agora/Karosa) from different PC systems without any other MM2 addons. IMO the final result is the same, a ZModeler vertices limit exists, exceed 65k for the body doesn't enable to play with a vehicle in-game.

FYI, the Pibraclab's Opel Astra V8 proposes a classic body with extremely detailed wheels. 26k faces, 45k vertices form the body in opposition to wheels, 50k faces, 136k vertices !! The car works perfectly in-game.

I succeeded by importing a car having more 200k faces and César more 400k but for the both, the vertices didn't exceed 60 or 65k.
_________________
Post 08 May 2008 12:54 pm
View user's profile Send private message Send e-mail Visit poster's website
Lex_Luther
Waterboy

Joined: 11 Jan 2008
Posts: 18


Status: Offline


Post subject: Reply with quote

Thanks Riva, for sharing your findings. Looks like the limit might actually be verticies, rather than polys/faces. I'll have to look into that. Since I did the first experiments with cones, which have more poly's per vertex, I'll re-do it with an object that has more verts.

So, In a car, the body objects are the only one's that use memory, and the wheels are unlimited? that's amazing that there wouldn't be a limit.

When you say the game "stopped loading" when you loaded a car w/ >65k verts, Did you get a "heap overrun" or did it just go back to the desktop. That sounds like what happened when I had too many high-poly cones loaded. As I approached an area with many of them near each other, it crahed to desktop- with no error. If you got a heap overrun, it would mean you just went over the limit- 65k Verts would be over 100k Faces. Did you try loading it in an empty city? I can email you the one I used if you like.
Post 09 May 2008 09:00 pm
View user's profile Send private message
Lex_Luther
Waterboy

Joined: 11 Jan 2008
Posts: 18


Status: Offline


Post subject: Reply with quote

Sorry for the double-post. I had to share these results!

I made an object that had 30k Verts and 10k Faces. Turns out that Verts use more memory than Faces, because I was expecting that 101 of these would load, but only 25 did. So I then made this object so it had 10kVerts.
Here are the number of objects I could place in an empty city before I would get the heap overrun:
1280x1024 63
1024x768 69
800x600 72
640x480 72
320x200 78

These results didn't make sense to me at first because the cone had 5k Verts and 10kFaces, so I was expecting it to crash around 50, but it took 69.

I put all the numbers into a spreadsheet, and here's what I got:


So that would make a memory usage formula like this:
Xresolution*Yresolution*2+VertexCount*16+FaceCount*4= about 13MB

I imagine the game has 16MB available, and is using the extra for internal use, or I could be wrong about the bytes used for the Video-mem, verts, or faces.
I'm going to do a similar bound test- will post those results later.
Post 10 May 2008 01:58 am
View user's profile Send private message
thenthornthing
MM2C Hooligan

Joined: 18 Jan 2007
Posts: 4409


Status: Offline


Post subject: Reply with quote

Very good stuff.
_________________
So it's "Goodnight" from me. And it's "Goodnight" from him. Goodnight!
Post 10 May 2008 06:12 am
View user's profile Send private message Send e-mail
Lex_Luther
Waterboy

Joined: 11 Jan 2008
Posts: 18


Status: Offline


Post subject: Reply with quote

Since the bounds use up more memory, I wanted to test which was more effiecient-- the text BND files or the binary BBND/TER files.
So I wrote a BoundConverter program to get the BND file from a BBND. The BND file seems to use less memory.
The problem however, is that the BND file that is produced acts weird. Only the ground is solid, and walls are only solid at the edges. Mad
The bound looks beautiful in Z-modeler, just a little darker than normal. Anyone know what might be going on??
If we can get it working properly, the program would allow modders to modify the original bound, instead of copying the H. which we now know is a huge waste.
Post 13 May 2008 01:51 am
View user's profile Send private message
HummersRock
...is still seeing colours.

Joined: 20 Feb 2006
Posts: 2669
Location: Magic Mushroom Land

Status: Offline


Post subject: Reply with quote

Lex_Luther wrote:
The problem however, is that the BND file that is produced acts weird. Only the ground is solid, and walls are only solid at the edges. Mad
The bound looks beautiful in Z-modeler, just a little darker than normal. Anyone know what might be going on??


Hmmm....that is odd. Very weird, actually, since you say it is fine in zmodeler. Did you do your exporting with zmodeler 1.05? If not try that. I really have no other ideas. Embarassed
_________________
My MM2 Creations | My DeviantArt
Post 13 May 2008 02:41 am
View user's profile Send private message Send e-mail Visit poster's website
Lex_Luther
Waterboy

Joined: 11 Jan 2008
Posts: 18


Status: Offline


Post subject: Reply with quote


No luck w/ Z-105...
The bound is showing up grey instead of white like everything normally is.
When I put it into the game as a pkg, it shows up very dark.
If I look at it from the bottom it's nice and white....
Could this be because of overlapping? I'm running out of ideas Crying or Very sad
Post 13 May 2008 05:37 am
View user's profile Send private message
Riva
Rivalicious

Joined: 29 Jan 2003
Posts: 1130
Location: Belgium

Status: Offline


Post subject: Reply with quote

Well I remember my preceding tests with bodies higher than 65k vertices, I had CTD, stopped loadings at 20% (approximately) but also a strange display in-game, several polys was scattered (sorry I don't have anymore pics, it would be necessary that I recover this car or that I remake tests).

TMK it was Speedtrack, an empty map of 2001 which I use for speeds max of the cars that I convert.

The BOUND object of cars are simple cubes having minimum 12 faces, maximum 16. I never tested or considering more.

About the BOUND map objects, MM2 CTK generates auto bound for each object. it's a simple copy of the original object. If the bound objects are darker than the others it's because those weren't calculated from ZModeler with this tool (Surface... > Normals > Calculate).
_________________
Post 13 May 2008 02:36 pm
View user's profile Send private message Send e-mail Visit poster's website
busboy99
MM2C Hooligan

Joined: 17 Feb 2006
Posts: 3607


Status: Offline


Post subject: Reply with quote

Extreamly good stuff! Cheers for sharing the results!
_________________
A boy was singing in a school hall when suddenly the immensity of the infinite universe hit him, and his eyes blasted out of their sockets and his lips burst and he fell to the ground and wept, his conciousness leaking out of his skull in gas form (which frightened the younger children).
- Chriddof
Also, I'm banned.
Post 13 May 2008 06:27 pm
View user's profile Send private message Send e-mail
Display posts from previous: Post new topicReply to topic

Page 1 of 2 All times are GMT
Goto page 1, 2  Next


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
Home - MM2C.com - Contact - Staff & Seniors - FAQ - Community Rules - Syndication


Powered by phpBB © 2001, 2005 phpBB Group