Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions related to memory use in Solidity or by nodes

2
votes
1answer
75 views

Why is the cost of memory non-linear, while the cost of storage is linear?

Why is the cost of memory non-linear, while the cost of storage is linear? I wonder why the cost function of memory vs. storage differ? While storage is associated with a constant cost, this is not ...
5
votes
1answer
272 views

How does dynamic array memory reallocating work?

Let's say I have a dynamic array of some length and I want to push a new element, but memory after last elem is already used. What would happen in such case? Compiler would find a new 'chunk' of ...
1
vote
1answer
102 views

Where does mapping store a variable if an address is already used?

I know that mapping use addresses, based on a hash of key + position of mapping storage variable keccak256(bytes32(variable_address) + bytes32(key)) And I want to know where variable would be stored ...
2
votes
1answer
250 views

Why does PUSH1 0x60 PUSH1 x40 MSTORE store 0x60 at memory location 0x50 (and not 0x40)?

According to browser solidity, after executing 000 PUSH1 60 002 PUSH1 40 004 MSTORE Memory is: 0x00: 00000000000000000000000000000000 ???????????????? 0x10: 00000000000000000000000000000000 ?????...
4
votes
1answer
409 views

Assigning an array creates a pointer or copies an array? (Solidity)

Here is the code: pragma solidity^0.4.16; contract Test { struct SomeData { address[] users; } address[] nullArray; mapping(uint => SomeData) SomeDataList; function ...
2
votes
1answer
1k views

Restrict CPU/memory usage of geth while syncing

I'm trying to run a geth node and a bitcoin core node on one server. I started with a DigitalOcean droplet with 2 CPU and 2GB memory, but both the geth and bitcoin node would run out of memory. I ...
4
votes
1answer
135 views

Why memory arrays are unresizable?

I don't know the required length of my array before execution of the function.. why technically can't I resize my memory array? What is the common way to go around of this problem, if you are also ...
2
votes
2answers
702 views

Is it possible to copy the internal storage of a smart contract to a new contract?

Assume that I want to implement my own version of a suicide contract function with extended functionality. More specifically, I want to copy the internal storage state of the contract to a new ...
2
votes
0answers
61 views

Assembly operations throw warnings during compiling

Leveraging the following common string utility has been quite helpful, but would like to get rid of a warning: function stringToBytes32(string memory source) returns (bytes32 result) { assembly ...
2
votes
2answers
371 views

How much memory do I need to mine any blocks on my lockal network?

I have linux box with 5Gb of memory: osboxes@osboxes ~/node1 $ free total used free shared buff/cache available Mem: 5176876 158360 3536464 ...
3
votes
1answer
625 views

Can I reduce the space chaindata takes up?

So the size of my chaindata folder has snowballed to close to 80GB. Is there a way to reduce it or is the only way to delete it and resync geth with --syncmode fast? Thanks!
18
votes
4answers
4k views

How to store IPFS hash using bytes?

Following Q/A (What datatype should I use for an IPFS address hash?) recommend us to use bytes to store IPFS hash. I was using following example(https://github.com/AdrianClv/ethereum-ipfs/blob/master/...
1
vote
0answers
527 views

Extreme memory consumption by geth

I'm using geth's traceTransaction() API to index certain opcodes that are used in transactions. When I request traces from some transactions (e.g. ...
2
votes
1answer
210 views

My disk has only 1 GB free - how can I use the Linux Ethereum Wallet?

I just downloaded the Ethereum Wallet for Debian Linux (I have Ubuntu 16.04). It appears to be downloading a lot of blocks: it now says that there are 3,310,606 blocks, and the number is decreasing. I ...
4
votes
1answer
88 views

What happens when memory is full in a node?

I am using go-ethereum and running a private blockchain network. I want to what is supposed to happen when the memory is full in the nodes. Will the program stop abruptly or will the old blocks get ...
1
vote
1answer
350 views

How to delete older blocks in a private blockchain network?

I would like to delete the old blocks when the memory is full in blocks. I understand that there will be loss of some data due to the deleting the blocks. But I think it would not change the structure ...
3
votes
1answer
739 views

How to make mining efficient in terms of memory, for a light weight client?

Since mining is resource intensive process, how to make it more efficient for a lightweight client in terms of memory. I am ready for a trade off even it takes more time to mine than what it would ...
4
votes
2answers
687 views

Invalid array length, expected integer literal

I'm trying to declare an in-memory array with a fixed length: uint length = 10; uint[length] memory priorityList; However, it just displays this error message: Invalid array length, expected ...
6
votes
1answer
184 views

Could more than one mapping's key point to the same memory space?

Since memory is already allocated on (array[0] = value;), I just want to change its pointing key value. Such as array[1] will allow me to access value now. Is it possible to change the key of ...
10
votes
3answers
4k views

How to run geth at 512Mb RAM Digital Ocean droplet?

When geth process consumes too much memory it gets killed (not at all gracefully) by Digital Ocean. Partly solved the problem by implementing swap - Setting up geth Ethereum node to run ...
3
votes
0answers
53 views

How does a plot “Gas price to call / memory allocated” looks like?

Pretty simple question: i.e. I have a dummy contract like this one: contract simple { uint[] dataArray; function push_one_more() { dataArray.push(1); } } How does the cost of ...
5
votes
1answer
2k views

Is it possible to decrease RAM usage of go-ethereum(geth)?

I have a slow computer, which has 2GB memory RAM. One geth app uses %60 percent of the RAM, which lead me to run only one geth node; I cannot run 2 geth nodes in parallel due to RAM overload. [Q] Is ...
0
votes
1answer
913 views

How can I create a solidity function that passes a storage pointer instead of creating a copy?

The following contract fails (I believe) because when Wordbase.set is called, it creates a new Node in storage, rather than passing the old Node. Thus, the value updates on the copy instead of the ...
9
votes
1answer
2k views

Does “delete” on mapping really frees the memory space?

I have the following mapping(uint => Foo[]) data structure. I have mapped 10 unique ids with 10 Foo structs, where each Foo is an arraylist of 10 items. Step 1: for(int i = 0; i < 10; i++) ...
5
votes
1answer
577 views

How to return dynamic sized array's original address on the memory of Solidity?

On the following source code, memOffset returns local values such as 96, 128 as the address value. How could I make it return the original address that is located on the memory, is it possible? After ...
4
votes
1answer
134 views

Is it possible to get an address of a struct in the Library or Contract without using mapping?

[Q] I was wondering is it possible to get an address of a struct on the memory space? Inside initialise() function after the Node object creation, I want to get is address if it is possible. Since ...
3
votes
1answer
449 views

Mist 0.8.6 crashing with Couldn't connect to node? See the logs for more

I have updated Ethereum-Wallet to 0.8.6. My accounts were not showing up in Wallet, so I deleted the .ethereum folder (after taking a backup) and restarted Wallet, but now I was unable to run wallet, ...
2
votes
1answer
52 views

Two ways of assigning a pointer. Is there a difference?

Here's one way to assign a pointer to variable z: function f(uint8[] memoryArray){ var z = memoryArray; } and here's another function f(uint8[] memoryArray){ uint8[] memory z = memoryArray; ...
4
votes
1answer
241 views

personal.newAccount(“mypassword”) stops the server when i create two accounts consecutively in local privatenet

personal.newAccount("mypassword") stops the server when i try to create two accounts one after the another. personal.unlockAccount(eth.accounts[0],"mypassword"); same happens when I try unlock ...
10
votes
2answers
820 views

error: Storage location can only be given for array or struct types

Getting the error "Storage location can only be given for array or struct types" in a setup function. The exact line is uint memory _total = 0; I'm confused by the error, because I'm not trying to ...
8
votes
1answer
779 views

What is the composition of the blockchain database?

From axic's explanation of the structure of the ethereum database, we learned that data is stored in Merkle Patricia tries, usually inside a LevelDB store. It consists of structures such as blocks, ...
18
votes
2answers
6k views

Can I save structs in a Mapping?

Is it possible to store structs in a Mapping or any dynamic memory structure in my Solidity SmartContract?
24
votes
1answer
11k views

What does the keyword “memory” do exactly?

I've been looking through the code of Etherdice and noticed that some variables are declared like ParserResult memory result; and I haven't found the keyword "memory" in any documentation. What I ...
4
votes
1answer
1k views

In solidity, how can I hardcode bytes > 32 bytes

I want to create a contract with a hardcoded bytes variable. contract Test(){ function Test(){ bytes x = 0x..... //greater than 32 bytes } } The above returns a Type int_const not ...
24
votes
3answers
6k views

Difference between Memory and Storage?

What is the difference between Memory and Storage ? From both the EVM point of view and the contract design one. Thanks!