Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


[java] RTTI & Garbage collection Question

This topic is 6308 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, here''s the situation. I''m working on a game where the end user will be able to create new game objects. Anyways I''m setting it up so that these new objects can spawn objects (e.g. a missile launcher spawns missile objects). Now each of these objects (missile and missile launcher) will reside in different files, and all object files will be loaded at load time. Due to the fact that I''m keeping objects seperate, and each object won''t know what objects actually reside in the system until load time (not compile time) I plan on using the Class class and the forName function. Class missileToSpawn = Class.forName("MyNewMissile"); Now because the MyNewMissile class was loaded into the RTTI at load time this should work fine. My question is -- Is the RTTI ever garbage collected? If so, does it follow that same rules as objects, as long as it is being referenced, it will exist. So by making missileToSpawn variable static, MyNewMissile will always reside in memory, therefore be quick to access? I can''t seem to find anything on the web, and my concern is speed. If the MyNewMissile class ever got garbage collected, the next time I tried to spawn one, there would be file access -- NOT GOOD. P.S. I''m keeping things seperate becuase I want other missile launcher classes be able to spawn this type of missile. But because things are in seperate files, I don''t want the MissileLauncher class to have direct access to MyNewMissile, I don''t know what would happen if someone downloaded the missile launcher class but not the MyNewMissile class. By doing it this way I can make the game engine simply invalidate the missile launcher class if a class by the name of "MyNewMissile" doesn''t exist in memory. I hope this message is clear enough. And thanks in advance if anyone out there can help. -Shaft

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!