| 1 | // Copyright (c) 2017-2022, The Monero Project |
| 2 | // |
| 3 | // All rights reserved. |
| 4 | // |
| 5 | // Redistribution and use in source and binary forms, with or without modification, are |
| 6 | // permitted provided that the following conditions are met: |
| 7 | // |
| 8 | // 1. Redistributions of source code must retain the above copyright notice, this list of |
| 9 | // conditions and the following disclaimer. |
| 10 | // |
| 11 | // 2. Redistributions in binary form must reproduce the above copyright notice, this list |
| 12 | // of conditions and the following disclaimer in the documentation and/or other |
| 13 | // materials provided with the distribution. |
| 14 | // |
| 15 | // 3. Neither the name of the copyright holder nor the names of its contributors may be |
| 16 | // used to endorse or promote products derived from this software without specific |
| 17 | // prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
| 20 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 22 | // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 24 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 25 | // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 26 | // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
| 27 | // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | |
| 29 | #include <map> |
| 30 | #include "cryptonote_basic/cryptonote_basic.h" |
| 31 | #include "cryptonote_basic/tx_extra.h" |
| 32 | #include "cryptonote_core/cryptonote_core.h" |
| 33 | #include "cryptonote_core/blockchain.h" |
| 34 | #include "p2p/p2p_protocol_defs.h" |
| 35 | #include "net/connection_basic.hpp" |
| 36 | #include "p2p/net_peerlist.h" |
| 37 | #include "p2p/net_node.h" |
| 38 | #include "cryptonote_protocol/cryptonote_protocol_handler.h" |
| 39 | #include "blockchain_db/lmdb/db_lmdb.h" |
| 40 | #include "wallet/wallet2.h" |
| 41 | #include "wallet/api/wallet.h" |
| 42 | #include "wallet/api/transaction_info.h" |
| 43 | #include "wallet/api/transaction_history.h" |
| 44 | #include "wallet/api/unsigned_transaction.h" |
| 45 | #include "wallet/api/pending_transaction.h" |
| 46 | |
| 47 | #undef MONERO_DEFAULT_LOG_CATEGORY |
| 48 | #define MONERO_DEFAULT_LOG_CATEGORY "debugtools.objectsizes" |
| 49 | |
| 50 | class size_logger |
| 51 | { |
| 52 | public: |
| 53 | ~size_logger() |
| 54 | { |
| 55 | for (const auto &i: types) |
| 56 | std::cout << std::to_string(i.first) << "\t" << i.second << std::endl; |
| 57 | } |
| 58 | void add(const char *type, size_t size) { types.insert(std::make_pair(size, type)); } |
| 59 | private: |
| 60 | std::multimap<size_t, const std::string> types; |
| 61 | }; |
| 62 | #define SL(type) sl.add(#type, sizeof(type)) |
| 63 | |
| 64 | int main(int argc, char* argv[]) |
| 65 | { |
| 66 | size_logger sl; |
| 67 | |
| 68 | tools::on_startup(); |
| 69 | |
| 70 | mlog_configure("", true); |
| 71 | |
| 72 | SL(boost::thread); |
| 73 | SL(boost::asio::io_service); |
| 74 | SL(boost::asio::io_service::work); |
| 75 | SL(boost::asio::deadline_timer); |
| 76 | |
| 77 | SL(cryptonote::DB_ERROR); |
| 78 | SL(cryptonote::mdb_txn_safe); |
| 79 | SL(cryptonote::mdb_threadinfo); |
| 80 | |
| 81 | SL(cryptonote::block_header); |
| 82 | SL(cryptonote::block); |
| 83 | SL(cryptonote::transaction_prefix); |
| 84 | SL(cryptonote::transaction); |
| 85 | |
| 86 | SL(cryptonote::txpool_tx_meta_t); |
| 87 | |
| 88 | SL(epee::net_utils::ipv4_network_address); |
| 89 | SL(epee::net_utils::network_address); |
| 90 | SL(epee::net_utils::connection_context_base); |
| 91 | SL(epee::net_utils::connection_basic); |
| 92 | |
| 93 | SL(nodetool::peerlist_entry); |
| 94 | SL(nodetool::anchor_peerlist_entry); |
| 95 | SL(nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core>>); |
| 96 | SL(nodetool::p2p_connection_context_t<cryptonote::t_cryptonote_protocol_handler<cryptonote::core>::connection_context>); |
| 97 | SL(nodetool::network_address_old); |
| 98 | SL(nodetool::peerlist_entry_base<nodetool::network_address_old>); |
| 99 | |
| 100 | SL(nodetool::network_config); |
| 101 | SL(nodetool::basic_node_data); |
| 102 | SL(cryptonote::CORE_SYNC_DATA); |
| 103 | |
| 104 | SL(tools::wallet2::transfer_details); |
| 105 | SL(tools::wallet2::payment_details); |
| 106 | SL(tools::wallet2::unconfirmed_transfer_details); |
| 107 | SL(tools::wallet2::confirmed_transfer_details); |
| 108 | SL(tools::wallet2::tx_construction_data); |
| 109 | SL(tools::wallet2::pending_tx); |
| 110 | SL(tools::wallet2::unsigned_tx_set); |
| 111 | SL(tools::wallet2::signed_tx_set); |
| 112 | |
| 113 | SL(Monero::WalletImpl); |
| 114 | SL(Monero::AddressBookRow); |
| 115 | SL(Monero::TransactionInfoImpl); |
| 116 | SL(Monero::TransactionHistoryImpl); |
| 117 | SL(Monero::PendingTransactionImpl); |
| 118 | SL(Monero::UnsignedTransactionImpl); |
| 119 | |
| 120 | return 0; |
| 121 | } |