Questions tagged [memory]

Questions related to memory use in Solidity or by nodes

Filter by
Sorted by
Tagged with
4 votes
3 answers
642 views

convert bytes to uint8[8] using mstore()

I know how to convert bytes to uint8[8] using mload but mstore seemed like it could be more gas efficient. Is something like this possible? function bytesToUintArray(bytes input) returns (uint8[8])) ...
antevirus's user avatar
3 votes
1 answer
138 views

Are balances of all accounts in memory or disk (storage)?

I simulated two contracts that sending balance to another and simply setting value of a variable(var a = 5;). In contrast my expectation, {var a = 5;} contract consumed more gas than the other. In my ...
송제호's user avatar
2 votes
1 answer
110 views

Examples of functions limitations?

I coded different functions and didn't find a standard that define crystal clear how many variables you can use (fields, local or as parameters of modifiers inside this function? Do you know a ...
Mario Granero's user avatar
1 vote
1 answer
12k views

Type error: memory is not implicitly convertible to expected type

I have a function that returns a list of BetProposition smart contracts: function getBetsForMatchup(uint matchupIdentifier) public returns (BetProposition[]) { return bets[matchupIdentifier]; ...
user339946's user avatar
2 votes
2 answers
3k views

Convert 'bytes memory' to 'bytes8'

In solidity, how can I convert bytes memory buffer to bytes8 type? Example: bytes8 buf2 = bytes8(memory_buf); // TypeError: Explicit type conversion not allowed
Alianse777's user avatar
1 vote
1 answer
4k views

Memory usage and limits for go-ethereum

geth (and swarm) seem to require a lot of memory, and there are also reports that they tend to an all you can eat approach to system limits. 1) What are the actual memory requirements for geth? 2) ...
lash's user avatar
  • 685
5 votes
2 answers
1k views

Stack too deep | Use memory array to store many "local" variables?

I have a contract that's doing a fairly complex calculation with some intermediate calculations, and I'm running into the "stack too deep" problem. I've tried to use a memory array within the ...
carlolm's user avatar
  • 2,316
1 vote
2 answers
97 views

Function that adds struct to an array in the blockchain does not execute when called by another function

I have a problem that's probably very basic, but I cannot seem to figure the issue out function _CreateBike(uint id, uint generation, string model, string ability, uint8 tier) internal returns(Bike){ ...
raghava pamula's user avatar
1 vote
2 answers
882 views

Is the EVM memory model a word array or byte array?

The yellow paper says that the memory model for the EVM is a word-addressed byte array (YP 9.1), but when I run debug.traceTransaction in Geth, the memory looks more like an array of words, maybe a ...
John Stanford's user avatar
0 votes
1 answer
1k views

string memory[3] memory is not implicitly convertible to expected type bytes32[] storage ref

I have the following (array of bytes32 types): bytes32[] public allTokenSymbols = ["0x4554480000000000000000000000000000000000000000000000000000000000", "...
ZhouW's user avatar
  • 1,348
1 vote
0 answers
429 views

For what data does Ethereum use Memory Database, and for what does it use Level Database

Ethereum uses two databases Memory database and Level Database. Is data stored in MemoryDatabase different than LevelDb? In what cases is one database used over other? The question is different from -...
Shubham Chaudhary's user avatar
0 votes
1 answer
341 views

Writing to contract struct via function parameter, memory vs storage, "memory outside of storage"

This is my first contract ever (building on an own example learning case I made up). Given this Contract (simplified): unit gEval = 0; contract Group { struct Grp { string name; uint ...
transient_loop's user avatar
2 votes
0 answers
133 views

Is it possible for a mapping to run out of space?

Can storage mappings in a contract run out of space? Say that mapping was keyed to an address and the value as the following struct: User bytes32 name uint8 age Theoretically, if there was a ...
The Nomad's user avatar
  • 399
1 vote
2 answers
438 views

If we create a ERC20 compliant token, how do we optimize address-balance mapping storage if we have a large user base?

I assume that the address-balance mapping array in ERC20 is considered as a storage variable. So say if 1 million users start to use token A, then there would be 1 million entries in the balance ...
Roger Ganga's user avatar
1 vote
1 answer
3k views

Hidden problems in "set array to empty array to clear it" approach

I needed a way to clear a storage array in my contract. I've seen this answer, but I tried to think of different approach (My arrays are most probably will contain enormous amount of elements) and ...
whyamiroot's user avatar
16 votes
3 answers
19k views

How to initialize an empty array inside a struct?

Is there a mistake in the way I initialize Bar b in the function foobar? contract Foo { struct Bar { address owner; uint[] x; } Bar[] public bars; function foobar(...
Manan Mehta's user avatar
1 vote
2 answers
656 views

Examples to clarify Storage vs Memory assignments / return parameters

Is there a mistake in funcB? I do not understand why/when to mention the variable name of the return parameter in the function signature. contract Foo { // State variables go to Storage uint[...
Manan Mehta's user avatar
2 votes
1 answer
2k views

Is there a maximum size for arrays in Solidity?

In my solidity code I define 3 arrays with around 700 elements inside. However, when I try to deploy the contract using Geth I am having the following error message: Error: oversized data undefined ...
Önder Gürcan's user avatar
6 votes
2 answers
4k views

Assigning memory variable to storage variable, what happens?

I'm curious what happens if you try to do the next thing: contract C { Struct S { uint a; uint b; } mapping(address => s) structs; function updateStructs(S ...
KwahuNashoba's user avatar
2 votes
1 answer
104 views

Is memory logged in a transaction?

Data in memory during a transaction is deleted when execution stops. This means this information is not stored in the contract state, but is the information that was in memory during the transaction ...
Curious2424's user avatar
2 votes
1 answer
215 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 ...
Shuzheng's user avatar
  • 1,815
6 votes
1 answer
686 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 ...
30mb1's user avatar
  • 369
1 vote
1 answer
543 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 ...
30mb1's user avatar
  • 369
6 votes
1 answer
7k views

Where are strings stored in Solidity?

I wonder where strings are stored in Solidity? Especially, where are string literals, function arguments, and variables stored? I recall, I've read that strings cannot be saved to memory, but is ...
Shuzheng's user avatar
  • 1,815
4 votes
1 answer
849 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 ?????...
user1234's user avatar
  • 329
6 votes
2 answers
3k 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 ...
30mb1's user avatar
  • 369
3 votes
1 answer
3k 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 ...
Inigo's user avatar
  • 131
11 votes
3 answers
2k 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 ...
EralpB's user avatar
  • 541
3 votes
2 answers
2k 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 ...
Mike B's user avatar
  • 131
2 votes
0 answers
91 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 ...
skarred14's user avatar
  • 945
2 votes
2 answers
521 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 ...
Stepan Yakovenko's user avatar
3 votes
1 answer
882 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!
Tomas Vrba's user avatar
34 votes
7 answers
16k views

How to store IPFS hash using bytes32?

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/...
alper's user avatar
  • 8,368
1 vote
0 answers
580 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. ...
Loonix Tarballs's user avatar
2 votes
1 answer
252 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 ...
Erel Segal-Halevi's user avatar
4 votes
1 answer
134 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 ...
spharish's user avatar
  • 287
1 vote
1 answer
808 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 ...
spharish's user avatar
  • 287
2 votes
1 answer
915 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 ...
Bhoopesh kumar goyal's user avatar
10 votes
2 answers
5k 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 ...
johnhckuo's user avatar
  • 341
6 votes
1 answer
256 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 ...
alper's user avatar
  • 8,368
13 votes
3 answers
6k 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 ...
takeshi's user avatar
  • 1,760
2 votes
0 answers
64 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 ...
Sergey Potekhin's user avatar
6 votes
1 answer
3k 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 ...
alper's user avatar
  • 8,368
0 votes
1 answer
1k 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 ...
Akhil F's user avatar
  • 1,908
11 votes
1 answer
3k 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++) ...
alper's user avatar
  • 8,368
4 votes
1 answer
1k 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 ...
alper's user avatar
  • 8,368
4 votes
1 answer
277 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 ...
alper's user avatar
  • 8,368
3 votes
1 answer
466 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, ...
Prashant Prabhakar Singh's user avatar
2 votes
1 answer
90 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; ...
manidos's user avatar
  • 4,278
4 votes
1 answer
393 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 ...
Priyanka D L's user avatar