Chris90909090909090 50 Posted August 24, 2022 Share Posted August 24, 2022 Wtf, this is amazing , befor 3,13 RAM after this 1,6 thats very nice thanks dude Link to comment Share on other sites More sharing options...
Flourine 106 Posted August 24, 2022 Share Posted August 24, 2022 4 hours ago, Chris90909090909090 said: Wtf, this is amazing , befor 3,13 RAM after this 1,6 thats very nice thanks dude 3,1 GB? wtf 1 Link to comment Share on other sites More sharing options...
Contributor Amun 1898 Posted September 8, 2022 Contributor Share Posted September 8, 2022 Pretty cool idea. By using what Marty posted here Spoiler The core reduced memory usage from 471 MB to 221, with a peak of 243 MB when booting(loading). Link to comment Share on other sites More sharing options...
Honorable Member martysama0134 7174 Posted September 8, 2022 Honorable Member Share Posted September 8, 2022 (edited) 6 hours ago, Amun said: By using what Marty posted here I've recently moved it outside PointsInstant (just for a better design style) CHARACTER_POINT_INSTANT m_pointsInstant; std::unique_ptr<PlayerSlotT> m_PlayerSlots; and included QuickSlot as well without any issues. (just check in char_quickslot.cpp if the unique_ptr is nullptr like always) struct PlayerSlotT { std::array<LPITEM,INVENTORY_AND_EQUIP_SLOT_MAX> pItems; std::array<BYTE,INVENTORY_AND_EQUIP_SLOT_MAX> bItemGrid; std::array<LPITEM,DRAGON_SOUL_INVENTORY_MAX_NUM> pDSItems; std::array<WORD,DRAGON_SOUL_INVENTORY_MAX_NUM> wDSItemGrid; std::array<LPITEM,CUBE_MAX_NUM> pCubeItems; #ifdef ENABLE_ACCE_COSTUME_SYSTEM std::array<TItemPosEx,ACCE_WINDOW_MAX_MATERIALS> pAcceMaterials; #endif std::array<TQuickslot,QUICKSLOT_MAX_NUM> pQuickslot; }; By using std::array instead of c-arrays, you'll get these differences: You may need to use XXX.data() to get the raw ptr in few occasions. memset is now useless garbage, because XXX = {} does that job for you You get assertions if the array subindex goes out of bound You can use all the generic features std:: containers support What doesn't change is that std::array is still considered a trivial type for the template trails, and can also be used for client<>server packets. Edited September 8, 2022 by martysama0134 3 1 2 5 Check out my GitHub Link to comment Share on other sites More sharing options...
Agares 1 Posted December 19, 2022 Share Posted December 19, 2022 The biggest fundamental flaw is that players and monsters use the same class and packet communication. This error causes unnecessary memory usage and unnecessarily long processing times. Action on this issue is only a minor improvement. More improvements should be made for large projects. All source code should be modular and independent of each other, with small packet communication and short processing times. 1 Link to comment Share on other sites More sharing options...
bossy_max 1 Posted January 2, 2023 Share Posted January 2, 2023 (edited) On 9/8/2022 at 5:36 PM, Amun said: Pretty cool idea. By using what Marty posted here Reveal hidden contents The core reduced memory usage from 471 MB to 221, with a peak of 243 MB when booting(loading). i did everything the same but there is such a bug https://metin2.download/picture/9Zj97oEe003IAgxykVqjZ4kYmlK86Z02/.png and i used unique_ptr instead of make_unique in part SetPlayerProto. Edited January 2, 2023 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
bossy_max 1 Posted January 2, 2023 Share Posted January 2, 2023 (edited) @ martysama0134what can I use instead of make_unique ? Edited January 2, 2023 by bossy_max Link to comment Share on other sites More sharing options...
Honorable Member martysama0134 7174 Posted January 2, 2023 Honorable Member Share Posted January 2, 2023 (edited) 1 hour ago, bossy_max said: @ martysama0134what can I use instead of make_unique ? This is its definition: template<typename T, typename... Args> std::unique_ptr<T> make_unique(Args&&... args) { return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); } Edited January 2, 2023 by martysama0134 Check out my GitHub Link to comment Share on other sites More sharing options...
bossy_max 1 Posted January 2, 2023 Share Posted January 2, 2023 8 hours ago, martysama0134 said: This is its definition: template<typename T, typename... Args> std::unique_ptr<T> make_unique(Args&&... args) { return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); } i will use it this thank you m_pointsInstant.playerSlots = std::unique_ptr<character_point_instant::PlayerSlotT>(new character_point_instant::PlayerSlotT()); Link to comment Share on other sites More sharing options...
[Dev]Medo 4 Posted May 6, 2023 Share Posted May 6, 2023 On 11/5/2021 at 1:20 PM, martysama0134 said: There are far better solutions than using std::map or std::unordered_map (which still takes a lot of ram for no reason for each mob): (I included the most important parts) You also forgot the CubeItems, and we could probably fit the quickslot too. Reveal hidden contents from running 1 channel - x3 cores on 2GB RAM and an additional 800MB swap -> running 4 channels - x12 cores on 2GB RAM and an additional 1.1GB swap this is huge Link to comment Share on other sites More sharing options...
Recommended Posts